home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume5 / smallc / part1 next >
Encoding:
Internet Message Format  |  1986-11-30  |  51.5 KB

  1. Subject: Small C compiler version C3.0R1.1 (part 1 of 3)
  2. Newsgroups: mod.sources
  3. Approved: jpn@panda.UUCP
  4.  
  5. Mod.sources:  Volume 5, Issue 7
  6. Submitted by: genrad!linus!mnetor!clewis (Chris Lewis)
  7.  
  8. There've been quite a few requests for this via net.micro.cpm, so's I
  9. thought I'd post it thru mod.sources.  This is Ron Cain's original Small
  10. C compiler, but highly extended.  Included are code generators for 8080,
  11. 6809, 68000, and VAX, as well as run-time support for 8080 CPM, VAX BSD4.1,
  12. and a FLEX 6809 environment.  See the README for a description of Small C's
  13. limitations.
  14.  
  15. #! /bin/sh
  16. # This is a shell archive, meaning:
  17. # 1. Remove everything above the #! /bin/sh line.
  18. # 2. Save the resulting text in a file.
  19. # 3. Execute the file with /bin/sh (not csh) to create the files:
  20. #    README
  21. #    M_README
  22. #    Makefile
  23. #    Makefile.bsd
  24. #    code8080.c
  25. #    codeas09.c
  26. #    codem68k.c
  27. #    codevax.c
  28. #    data.c
  29. #    data.h
  30. # This archive created: Sun May 18 18:28:42 1986
  31. export PATH; PATH=/bin:$PATH
  32. echo shar: extracting "'README'" '(2959 characters)'
  33. if test -f 'README'
  34. then
  35.     echo shar: will not over-write existing file "'README'"
  36. else
  37. cat << \SHAR_EOF > 'README'
  38.             Small C version C3.0R1.1
  39.                   (SCC3)
  40.  
  41.                 Chris Lewis
  42.  
  43. This directory contains the source for a version of Ron Cain's Small C 
  44. compiler that I have heavily modified - beyond the Small-C V2.0 later
  45. published in Dr. Dobbs.  This compiler generates assembler source code that
  46. needs to be assembled and linked to make a running program.
  47.  
  48. Small C is a public domain compiler for a subset of C.  The main things
  49. lacking are "#if", structs/unions, doubles/floats/longs and more than
  50. one level of indirection.  Even so, it's powerful enough to be able to
  51. compile itself.  It's also lots of fun to play around with.  It could
  52. use lots of more work (eg: a real scanner), but what the heck...
  53. Retargetting the compiler requires only relinking the frontend with a new
  54. code generator.
  55.  
  56. Code generators for 6809 (MIT UNIX-like assembler), M68K (Motorola V/68 UNIX
  57. assembler), VAX (BSD 4.1 assembler), and 8080 (RMAC assembler) are provided.
  58.  
  59. Users having access to System V make should be able to use the Makefile 
  60. without any modification except for INCDIR and LIBDIR (where you'd like 
  61. to put the compiler itself).
  62.  
  63. Users not having access to System V will probably have to rewrite the Makefile.
  64. [ I have provided a Makefile that seems to work with bsd systems - mod]
  65.  
  66. WARNING: you will probably see a great deal of compilation warnings when
  67. you compile this compiler with a "real" UNIX C.  Don't worry - this is
  68. *perfectly* normal - Small C is a subset of real C, and in order to
  69. keep the compiler in this subset you have to bend the rules somewhat.
  70. The only time where this might cause a problem is where pointers are
  71. "different" from ints (ie: different length or on non-byte-addressible
  72. machines).  Small C assumes that ints are the same as pointers.
  73.  
  74. Invocation:
  75.     scc<6809|vax|m68k|8080> filename
  76.  
  77. There are other options available - see main.c for details.
  78.  
  79. The code generated by these compilers need a run-time support library
  80. for two things: operations that are "hard" on a particular processor
  81. (eg: 16 bit multiply on an 8080), or O/S interface (vax is BSD 4.1,
  82. 6809 is FLEX, 8080 is CPM, never had one for M68k).
  83.  
  84. Status: the 6809, VAX and 8080 versions work last I checked - a problem or
  85. two may have crept in during the implementation of the compile/assemble/and
  86. link code for machines that support it.  The M68k version has never been
  87. tested.  I don't have a Pyramid version because Pyrcorp seems reluctant
  88. to publish instruction set information.
  89.  
  90. So you want to write a new coder do you?  Well, it's easy - read the
  91. comments in one of the coders.  You should not have to modify *any* of
  92. the existing files, just write a new codexxx.c file.  Please contact
  93. me if you run into trouble.  I would be greatly interested in any new
  94. coders or bug reports in the compilers.  As far as I am aware, the
  95. major restriction on porting this thing for different targets is that
  96. pointers and integers *must* be the same length, alignment, and be
  97. interchangeable.
  98. SHAR_EOF
  99. if test 2959 -ne "`wc -c < 'README'`"
  100. then
  101.     echo shar: error transmitting "'README'" '(should have been 2959 characters)'
  102. fi
  103. fi
  104. echo shar: extracting "'M_README'" '(550 characters)'
  105. if test -f 'M_README'
  106. then
  107.     echo shar: will not over-write existing file "'M_README'"
  108. else
  109. cat << \SHAR_EOF > 'M_README'
  110.         ***  Moderator's README ***
  111.  
  112. This directory contains the base source code for the smallC compiler
  113. (actually three versions:  the 8080, 6809 and vax code generators are
  114. here also.)
  115.  
  116. The "includes" directory contains headers which are intended to be included in
  117. user programs - the place where these files reside should be set in the Makefile
  118. as INCDIR.  The directories "6809", "8080", and "vax" contain runtime support
  119. for the respective compilers.  The directory "lib" contains the source code
  120. for some common C library functions (portable ones).
  121. SHAR_EOF
  122. if test 550 -ne "`wc -c < 'M_README'`"
  123. then
  124.     echo shar: error transmitting "'M_README'" '(should have been 550 characters)'
  125. fi
  126. fi
  127. echo shar: extracting "'Makefile'" '(1429 characters)'
  128. if test -f 'Makefile'
  129. then
  130.     echo shar: will not over-write existing file "'Makefile'"
  131. else
  132. cat << \SHAR_EOF > 'Makefile'
  133. #    Requires System V make
  134. #    @(#)Makefile 1.5 86/05/13
  135. .SUFFIXES:    .o .c .c~ .h .h~
  136. .PRECIOUS:    scclib.a
  137. #    You'll probabably want to change these.  These are used by the compilers#    to figure out where the include files should go.
  138. TARGDIR = /u/clewis/lib
  139. INCDIR = "/u/clewis/src/scc/include/"
  140.  
  141. INSTFLAGS = -DINCDIR=$(INCDIR)
  142. CFLAGS = '$(INSTFLAGS)' -O
  143. AR = ar
  144. ARFLAGS = rv
  145.  
  146. LIB = scclib.a
  147.  
  148. FE =    $(LIB)(data.o) \
  149.     $(LIB)(error.o) \
  150.     $(LIB)(expr.o) \
  151.     $(LIB)(function.o) \
  152.     $(LIB)(gen.o) \
  153.     $(LIB)(io.o) \
  154.     $(LIB)(lex.o) \
  155.     $(LIB)(main.o) \
  156.     $(LIB)(preproc.o) \
  157.     $(LIB)(primary.o) \
  158.     $(LIB)(stmt.o) \
  159.     $(LIB)(sym.o) \
  160.     $(LIB)(while.o)
  161.  
  162. all:    scc8080 sccas09 sccvax sccm68k
  163.  
  164. $(FE) code8080.o codeas09.o codevax.o codem68k.o: defs.h data.h
  165.  
  166. install:    all
  167.     mv sccvax scc8080 sccas09 sccm68k $(TARGDIR)
  168.  
  169. #Alternately, you may have to do an lorder
  170. $(LIB):    $(FE)
  171.     -ranlib $(LIB)
  172.     -ucb ranlib $(LIB)
  173.  
  174. scc8080:    code8080.o $(LIB)
  175.     $(CC) -o scc8080 $(CFLAGS) $(LIB) code8080.o
  176.  
  177. sccas09:    codeas09.o $(LIB)
  178.     $(CC) -o sccas09 $(CFLAGS) $(LIB) codeas09.o
  179.  
  180. sccvax:        codevax.o $(LIB)
  181.     $(CC) -o sccvax $(CFLAGS) $(LIB) codevax.o
  182.  
  183. sccm68k:    codem68k.o $(LIB)
  184.     $(CC) -o sccm68k $(CFLAGS) $(LIB) codem68k.o
  185.  
  186. print:
  187.     pr -n defs.h data.h data.c error.c expr.c function.c gen.c \
  188.         io.c lex.c main.c preproc.c primary.c stmt.c \
  189.         sym.c while.c code*.c | lp
  190. clean:
  191.     rm -f $(LIB) code8080.o codeas09.o codevax.o codem68k.o \
  192.              sccvax scc8080 sccas09 sccm68k
  193. SHAR_EOF
  194. if test 1429 -ne "`wc -c < 'Makefile'`"
  195. then
  196.     echo shar: error transmitting "'Makefile'" '(should have been 1429 characters)'
  197. fi
  198. fi
  199. echo shar: extracting "'Makefile.bsd'" '(1359 characters)'
  200. if test -f 'Makefile.bsd'
  201. then
  202.     echo shar: will not over-write existing file "'Makefile.bsd'"
  203. else
  204. cat << \SHAR_EOF > 'Makefile.bsd'
  205. #    I couldn't get the supplied makefile to work, so I wrote one for
  206. #       BSD systems      - John Nelson, moderator, mod.sources
  207. #
  208. #    You'll probabably want to change these.  These are used by the compilers#    to figure out where the include files should go.
  209. TARGDIR = /u/clewis/lib
  210. INCDIR = "/u/clewis/src/scc/include/"
  211.  
  212. INSTFLAGS = -DINCDIR=$(INCDIR)
  213. CFLAGS = '$(INSTFLAGS)' -O
  214. AR = ar
  215. ARFLAGS = rv
  216.  
  217. LIB = scclib.a
  218.  
  219. FE =    data.o \
  220.     error.o \
  221.     expr.o \
  222.     function.o \
  223.     gen.o \
  224.     io.o \
  225.     lex.o \
  226.     main.o \
  227.     preproc.o \
  228.     primary.o \
  229.     stmt.o \
  230.     sym.o \
  231.     while.o
  232.  
  233. all:    scc8080 sccas09 sccvax sccm68k
  234.  
  235. $(FE) code8080.o codeas09.o codevax.o codem68k.o: defs.h data.h
  236.  
  237. install:    all
  238.     mv sccvax scc8080 sccas09 sccm68k $(TARGDIR)
  239.  
  240. #Alternately, you may have to do an lorder
  241. $(LIB):    $(FE)
  242.     -rm $@
  243.     ar q $@ $(FE)
  244.     -ranlib $(LIB)
  245.  
  246. scc8080:    code8080.o $(LIB)
  247.     $(CC) -o scc8080 $(CFLAGS) $(LIB) code8080.o
  248.  
  249. sccas09:    codeas09.o $(LIB)
  250.     $(CC) -o sccas09 $(CFLAGS) $(LIB) codeas09.o
  251.  
  252. sccvax:        codevax.o $(LIB)
  253.     $(CC) -o sccvax $(CFLAGS) $(LIB) codevax.o
  254.  
  255. sccm68k:    codem68k.o $(LIB)
  256.     $(CC) -o sccm68k $(CFLAGS) $(LIB) codem68k.o
  257.  
  258. print:
  259.     pr -n defs.h data.h data.c error.c expr.c function.c gen.c \
  260.         io.c lex.c main.c preproc.c primary.c stmt.c \
  261.         sym.c while.c code*.c | lp
  262. clean:
  263.     rm -f $(LIB) code8080.o codeas09.o codevax.o codem68k.o \
  264.              sccvax scc8080 sccas09 sccm68k
  265. SHAR_EOF
  266. if test 1359 -ne "`wc -c < 'Makefile.bsd'`"
  267. then
  268.     echo shar: error transmitting "'Makefile.bsd'" '(should have been 1359 characters)'
  269. fi
  270. fi
  271. echo shar: extracting "'code8080.c'" '(9671 characters)'
  272. if test -f 'code8080.c'
  273. then
  274.     echo shar: will not over-write existing file "'code8080.c'"
  275. else
  276. cat << \SHAR_EOF > 'code8080.c'
  277. /*    File code8080.c: 2.2 (84/08/31,10:05:09) */
  278. /*% cc -O -c %
  279.  *
  280.  */
  281.  
  282. #include <stdio.h>
  283. #include "defs.h"
  284. #include "data.h"
  285.  
  286. /*    Define ASNM and LDNM to the names of the assembler and linker
  287.     respectively */
  288.  
  289. /*
  290.  *    Some predefinitions:
  291.  *
  292.  *    INTSIZE is the size of an integer in the target machine
  293.  *    BYTEOFF is the offset of an byte within an integer on the
  294.  *        target machine. (ie: 8080,pdp11 = 0, 6809 = 1,
  295.  *        360 = 3)
  296.  *    This compiler assumes that an integer is the SAME length as
  297.  *    a pointer - in fact, the compiler uses INTSIZE for both.
  298.  */
  299. #define    INTSIZE    2
  300. #define    BYTEOFF    0
  301.  
  302. /*
  303.  *    print all assembler info before any code is generated
  304.  *
  305.  */
  306. header ()
  307. {
  308.     outstr (";    Small C 8080;\n;\tCoder (2.4,84/11/27)\n;");
  309.     FEvers();
  310.     nl ();
  311.     ol ("extrn    ?gchar,?gint,?pchar,?pint,?bool");
  312.     ol ("extrn    ?sxt");
  313.     ol ("extrn    ?or,?and,?xor");
  314.     ol ("extrn    ?eq,?ne,?gt,?le,?ge,?lt,?uge,?ult,?ugt,?ule");
  315.     ol ("extrn    ?asr,?asl");
  316.     ol ("extrn    ?sub,?neg,?com,?lneg,?mul,?div");
  317.     ol ("extrn    ?case");
  318. }
  319.  
  320. nl ()
  321. {
  322.     outbyte (EOL);
  323. }
  324. initmac()
  325. {
  326.     defmac("cpm\t1");
  327.     defmac("I8080\t1");
  328.     defmac("RMAC\t1");
  329.     defmac("smallc\t1");
  330. }
  331.  
  332. galign(t)
  333. int    t;
  334. {
  335.     return(t);
  336. }
  337.  
  338. /*
  339.  *    return size of an integer
  340.  */
  341. intsize() {
  342.     return(INTSIZE);
  343. }
  344.  
  345. /*
  346.  *    return offset of ls byte within word
  347.  *    (ie: 8080 & pdp11 is 0, 6809 is 1, 360 is 3)
  348.  */
  349. byteoff() {
  350.     return(BYTEOFF);
  351. }
  352.  
  353. /*
  354.  *    Output internal generated label prefix
  355.  */
  356. olprfix() {
  357.     outbyte('?');
  358. }
  359.  
  360. /*
  361.  *    Output a label definition terminator
  362.  */
  363. col ()
  364. {
  365.     outbyte (58);
  366. }
  367.  
  368. /*
  369.  *    begin a comment line for the assembler
  370.  *
  371.  */
  372. comment ()
  373. {
  374.     outbyte (';');
  375. }
  376.  
  377. /*
  378.  *    Emit user label prefix
  379.  */
  380. prefix ()
  381. {
  382. }
  383.  
  384.  
  385. /*
  386.  *    print any assembler stuff needed after all code
  387.  *
  388.  */
  389. trailer ()
  390. {
  391.     ol ("end");
  392. }
  393.  
  394. /*
  395.  *    function prologue
  396.  */
  397. prologue ()
  398. {
  399. }
  400.  
  401. /*
  402.  *    text (code) segment
  403.  */
  404. gtext ()
  405. {
  406.     ol ("cseg");
  407. }
  408.  
  409. /*
  410.  *    data segment
  411.  */
  412. gdata ()
  413. {
  414.     ol ("dseg");
  415. }
  416.  
  417. /*
  418.  *  Output the variable symbol at scptr as an extrn or a public
  419.  */
  420. ppubext(scptr) char *scptr; {
  421.     if (cptr[STORAGE] == STATIC) return;
  422.     ot (scptr[STORAGE] == EXTERN ? "extrn\t" : "public\t");
  423.     prefix ();
  424.     outstr (scptr);
  425.     nl();
  426. }
  427.  
  428. /*
  429.  * Output the function symbol at scptr as an extrn or a public
  430.  */
  431. fpubext(scptr) char *scptr; {
  432.     if (scptr[STORAGE] == STATIC) return;
  433.     ot (scptr[OFFSET] == FUNCTION ? "public\t" : "extrn\t");
  434.     prefix ();
  435.     outstr (scptr);
  436.     nl ();
  437. }
  438.  
  439. /*
  440.  *  Output a decimal number to the assembler file
  441.  */
  442. onum(num) int num; {
  443.     outdec(num);    /* pdp11 needs a "." here */
  444. }
  445.  
  446.  
  447. /*
  448.  *    fetch a static memory cell into the primary register
  449.  */
  450. getmem (sym)
  451. char    *sym;
  452. {
  453.     if ((sym[IDENT] != POINTER) & (sym[TYPE] == CCHAR)) {
  454.         ot ("lda\t");
  455.         outstr (sym + NAME);
  456.         nl ();
  457.         gcall ("?sxt");
  458.     } else {
  459.         ot ("lhld\t");
  460.         outstr (sym + NAME);
  461.         nl ();
  462.     }
  463. }
  464.  
  465. /*
  466.  *    fetch the address of the specified symbol into the primary register
  467.  *
  468.  */
  469. getloc (sym)
  470. char    *sym;
  471. {
  472.     immed ();
  473.     if (sym[STORAGE] == LSTATIC) {
  474.         printlabel(glint(sym));
  475.         nl();
  476.     } else {
  477.         outdec (glint(sym) - stkp);
  478.         nl ();
  479.         ol ("dad\tsp");
  480.     }
  481. }
  482.  
  483. /*
  484.  *    store the primary register into the specified static memory cell
  485.  *
  486.  */
  487. putmem (sym)
  488. char    *sym;
  489. {
  490.     if ((sym[IDENT] != POINTER) & (sym[TYPE] == CCHAR)) {
  491.         ol ("mov\ta,l");
  492.         ot ("sta\t");
  493.     } else
  494.         ot ("shld\t");
  495.     outstr (sym + NAME);
  496.     nl ();
  497. }
  498.  
  499. /*
  500.  *    store the specified object type in the primary register
  501.  *    at the address on the top of the stack
  502.  *
  503.  */
  504. putstk (typeobj)
  505. char    typeobj;
  506. {
  507.     gpop ();
  508.     if (typeobj == CCHAR)
  509.         gcall ("?pchar");
  510.     else
  511.         gcall ("?pint");
  512. }
  513.  
  514. /*
  515.  *    fetch the specified object type indirect through the primary
  516.  *    register into the primary register
  517.  *
  518.  */
  519. indirect (typeobj)
  520. char    typeobj;
  521. {
  522.     if (typeobj == CCHAR)
  523.         gcall ("?gchar");
  524.     else
  525.         gcall ("?gint");
  526. }
  527.  
  528. /*
  529.  *    swap the primary and secondary registers
  530.  *
  531.  */
  532. swap ()
  533. {
  534.     ol ("xchg");
  535. }
  536.  
  537. /*
  538.  *    print partial instruction to get an immediate value into
  539.  *    the primary register
  540.  *
  541.  */
  542. immed ()
  543. {
  544.     ot ("lxi\th,");
  545. }
  546.  
  547. /*
  548.  *    push the primary register onto the stack
  549.  *
  550.  */
  551. gpush ()
  552. {
  553.     ol ("push\th");
  554.     stkp = stkp - INTSIZE;
  555. }
  556.  
  557. /*
  558.  *    pop the top of the stack into the secondary register
  559.  *
  560.  */
  561. gpop ()
  562. {
  563.     ol ("pop\td");
  564.     stkp = stkp + INTSIZE;
  565. }
  566.  
  567. /*
  568.  *    swap the primary register and the top of the stack
  569.  *
  570.  */
  571. swapstk ()
  572. {
  573.     ol ("xthl");
  574. }
  575.  
  576. /*
  577.  *    call the specified subroutine name
  578.  *
  579.  */
  580. gcall (sname)
  581. char    *sname;
  582. {
  583.     ot ("call\t");
  584.     outstr (sname);
  585.     nl ();
  586. }
  587.  
  588. /*
  589.  *    return from subroutine
  590.  *
  591.  */
  592. gret ()
  593. {
  594.     ol ("ret");
  595. }
  596.  
  597. /*
  598.  *    perform subroutine call to value on top of stack
  599.  *
  600.  */
  601. callstk ()
  602. {
  603.     immed ();
  604.     outstr ("$+5");
  605.     nl ();
  606.     swapstk ();
  607.     ol ("pchl");
  608.     stkp = stkp + INTSIZE;
  609. }
  610.  
  611. /*
  612.  *    jump to specified internal label number
  613.  *
  614.  */
  615. jump (label)
  616. int    label;
  617. {
  618.     ot ("jmp\t");
  619.     printlabel (label);
  620.     nl ();
  621. }
  622.  
  623. /*
  624.  *    test the primary register and jump if false to label
  625.  *
  626.  */
  627. testjump (label, ft)
  628. int    label,
  629.     ft;
  630. {
  631.     ol ("mov\ta,h");
  632.     ol ("ora\tl");
  633.     if (ft)
  634.         ot ("jnz\t");
  635.     else
  636.         ot ("jz\t");
  637.     printlabel (label);
  638.     nl ();
  639. }
  640.  
  641. /*
  642.  *    print pseudo-op  to define a byte
  643.  *
  644.  */
  645. defbyte ()
  646. {
  647.     ot ("db\t");
  648. }
  649.  
  650. /*
  651.  *    print pseudo-op to define storage
  652.  *
  653.  */
  654. defstorage ()
  655. {
  656.     ot ("ds\t");
  657. }
  658.  
  659. /*
  660.  *    print pseudo-op to define a word
  661.  *
  662.  */
  663. defword ()
  664. {
  665.     ot ("dw\t");
  666. }
  667.  
  668. /*
  669.  *    modify the stack pointer to the new value indicated
  670.  *
  671.  */
  672. modstk (newstkp)
  673. int    newstkp;
  674. {
  675.     int    k;
  676.  
  677.     k = galign(newstkp - stkp);
  678.     if (k == 0)
  679.         return (newstkp);
  680.     if (k > 0) {
  681.         if (k < 7) {
  682.             if (k & 1) {
  683.                 ol ("inx\tsp");
  684.                 k--;
  685.             }
  686.             while (k) {
  687.                 ol ("pop\tb");
  688.                 k = k - INTSIZE;
  689.             }
  690.             return (newstkp);
  691.         }
  692.     } else {
  693.         if (k > -7) {
  694.             if (k & 1) {
  695.                 ol ("dcx\tsp");
  696.                 k++;
  697.             }
  698.             while (k) {
  699.                 ol ("push\tb");
  700.                 k = k + INTSIZE;
  701.             }
  702.             return (newstkp);
  703.         }
  704.     }
  705.     swap ();
  706.     immed ();
  707.     outdec (k);
  708.     nl ();
  709.     ol ("dad\tsp");
  710.     ol ("sphl");
  711.     swap ();
  712.     return (newstkp);
  713. }
  714.  
  715. /*
  716.  *    multiply the primary register by INTSIZE
  717.  */
  718. gaslint ()
  719. {
  720.     ol ("dad\th");
  721. }
  722.  
  723. /*
  724.  *    divide the primary register by INTSIZE
  725.  */
  726. gasrint()
  727. {
  728.     gpush();    /* push primary in prep for gasr */
  729.     immed ();
  730.     onum (1);
  731.     nl ();
  732.     gasr ();  /* divide by two */
  733. }
  734.  
  735. /*
  736.  *    Case jump instruction
  737.  */
  738. gjcase() {
  739.     ot ("jmp\t?case");
  740.     nl ();
  741. }
  742.  
  743. /*
  744.  *    add the primary and secondary registers
  745.  *    if lval2 is int pointer and lval is not, scale lval
  746.  */
  747. gadd (lval,lval2) int *lval,*lval2;
  748. {
  749.     gpop ();
  750.     if (dbltest (lval2, lval)) {
  751.         swap ();
  752.         gaslint ();
  753.         swap ();
  754.     }
  755.     ol ("dad\td");
  756. }
  757.  
  758. /*
  759.  *    subtract the primary register from the secondary
  760.  *
  761.  */
  762. gsub ()
  763. {
  764.     gpop ();
  765.     gcall ("?sub");
  766. }
  767.  
  768. /*
  769.  *    multiply the primary and secondary registers
  770.  *    (result in primary)
  771.  *
  772.  */
  773. gmult ()
  774. {
  775.     gpop();
  776.     gcall ("?mul");
  777. }
  778.  
  779. /*
  780.  *    divide the secondary register by the primary
  781.  *    (quotient in primary, remainder in secondary)
  782.  *
  783.  */
  784. gdiv ()
  785. {
  786.     gpop();
  787.     gcall ("?div");
  788. }
  789.  
  790. /*
  791.  *    compute the remainder (mod) of the secondary register
  792.  *    divided by the primary register
  793.  *    (remainder in primary, quotient in secondary)
  794.  *
  795.  */
  796. gmod ()
  797. {
  798.     gdiv ();
  799.     swap ();
  800. }
  801.  
  802. /*
  803.  *    inclusive 'or' the primary and secondary registers
  804.  *
  805.  */
  806. gor ()
  807. {
  808.     gpop();
  809.     gcall ("?or");
  810. }
  811.  
  812. /*
  813.  *    exclusive 'or' the primary and secondary registers
  814.  *
  815.  */
  816. gxor ()
  817. {
  818.     gpop();
  819.     gcall ("?xor");
  820. }
  821.  
  822. /*
  823.  *    'and' the primary and secondary registers
  824.  *
  825.  */
  826. gand ()
  827. {
  828.     gpop();
  829.     gcall ("?and");
  830. }
  831.  
  832. /*
  833.  *    arithmetic shift right the secondary register the number of
  834.  *    times in the primary register
  835.  *    (results in primary register)
  836.  *
  837.  */
  838. gasr ()
  839. {
  840.     gpop();
  841.     gcall ("?asr");
  842. }
  843.  
  844. /*
  845.  *    arithmetic shift left the secondary register the number of
  846.  *    times in the primary register
  847.  *    (results in primary register)
  848.  *
  849.  */
  850. gasl ()
  851. {
  852.     gpop ();
  853.     gcall ("?asl");
  854. }
  855.  
  856. /*
  857.  *    two's complement of primary register
  858.  *
  859.  */
  860. gneg ()
  861. {
  862.     gcall ("?neg");
  863. }
  864.  
  865. /*
  866.  *    logical complement of primary register
  867.  *
  868.  */
  869. glneg ()
  870. {
  871.     gcall ("?lneg");
  872. }
  873.  
  874. /*
  875.  *    one's complement of primary register
  876.  *
  877.  */
  878. gcom ()
  879. {
  880.     gcall ("?com");
  881. }
  882.  
  883. /*
  884.  *    Convert primary value into logical value (0 if 0, 1 otherwise)
  885.  *
  886.  */
  887. gbool ()
  888. {
  889.     gcall ("?bool");
  890. }
  891.  
  892. /*
  893.  *    increment the primary register by 1 if char, INTSIZE if
  894.  *      int
  895.  */
  896. ginc (lval) int lval[];
  897. {
  898.     ol ("inx\th");
  899.     if (lval[2] == CINT)
  900.         ol ("inx\th");
  901. }
  902.  
  903. /*
  904.  *    decrement the primary register by one if char, INTSIZE if
  905.  *    int
  906.  */
  907. gdec (lval) int lval[];
  908. {
  909.     ol ("dcx\th");
  910.     if (lval[2] == CINT)
  911.         ol("dcx\th");
  912. }
  913.  
  914. /*
  915.  *    following are the conditional operators.
  916.  *    they compare the secondary register against the primary register
  917.  *    and put a literl 1 in the primary if the condition is true,
  918.  *    otherwise they clear the primary register
  919.  *
  920.  */
  921.  
  922. /*
  923.  *    equal
  924.  *
  925.  */
  926. geq ()
  927. {
  928.     gpop();
  929.     gcall ("?eq");
  930. }
  931.  
  932. /*
  933.  *    not equal
  934.  *
  935.  */
  936. gne ()
  937. {
  938.     gpop();
  939.     gcall ("?ne");
  940. }
  941.  
  942. /*
  943.  *    less than (signed)
  944.  *
  945.  */
  946. glt ()
  947. {
  948.     gpop();
  949.     gcall ("?lt");
  950. }
  951.  
  952. /*
  953.  *    less than or equal (signed)
  954.  *
  955.  */
  956. gle ()
  957. {
  958.     gpop();
  959.     gcall ("?le");
  960. }
  961.  
  962. /*
  963.  *    greater than (signed)
  964.  *
  965.  */
  966. ggt ()
  967. {
  968.     gpop();
  969.     gcall ("?gt");
  970. }
  971.  
  972. /*
  973.  *    greater than or equal (signed)
  974.  *
  975.  */
  976. gge ()
  977. {
  978.     gpop();
  979.     gcall ("?ge");
  980. }
  981.  
  982. /*
  983.  *    less than (unsigned)
  984.  *
  985.  */
  986. gult ()
  987. {
  988.     gpop();
  989.     gcall ("?ult");
  990. }
  991.  
  992. /*
  993.  *    less than or equal (unsigned)
  994.  *
  995.  */
  996. gule ()
  997. {
  998.     gpop();
  999.     gcall ("?ule");
  1000. }
  1001.  
  1002. /*
  1003.  *    greater than (unsigned)
  1004.  *
  1005.  */
  1006. gugt ()
  1007. {
  1008.     gpop();
  1009.     gcall ("?ugt");
  1010. }
  1011.  
  1012. /*
  1013.  *    greater than or equal (unsigned)
  1014.  *
  1015.  */
  1016. guge ()
  1017. {
  1018.     gpop();
  1019.     gcall ("?uge");
  1020. }
  1021.  
  1022. inclib() {
  1023. #ifdef    cpm
  1024.     return("B:");
  1025. #endif
  1026. #ifdef    unix
  1027.     return(INCDIR);
  1028. #endif
  1029. }
  1030.  
  1031. /*    Squirrel away argument count in a register that modstk
  1032.     doesn't touch.
  1033. */
  1034.  
  1035. gnargs(d)
  1036. int    d; {
  1037.     ot ("mvi\ta,");
  1038.     onum(d);
  1039.     nl ();
  1040. }
  1041.  
  1042. assemble(s)
  1043. char    *s; {
  1044. #ifdef    ASNM
  1045.     char buf[100];
  1046.     strcpy(buf, ASNM);
  1047.     strcat(buf, " ");
  1048.     strcat(buf, s);
  1049.     buf[strlen(buf)-1] = 's';
  1050.     return(system(buf));
  1051. #else
  1052.     return(0);
  1053. #endif
  1054. }
  1055.  
  1056. link() {
  1057. #ifdef    LDNM
  1058.     fputs("I don't know how to link files yet\n", stderr);
  1059. #else
  1060.     return(0);
  1061. #endif
  1062. }
  1063. SHAR_EOF
  1064. if test 9671 -ne "`wc -c < 'code8080.c'`"
  1065. then
  1066.     echo shar: error transmitting "'code8080.c'" '(should have been 9671 characters)'
  1067. fi
  1068. fi
  1069. echo shar: extracting "'codeas09.c'" '(9534 characters)'
  1070. if test -f 'codeas09.c'
  1071. then
  1072.     echo shar: will not over-write existing file "'codeas09.c'"
  1073. else
  1074. cat << \SHAR_EOF > 'codeas09.c'
  1075. /*    File codeas09.c: 2.2 (84/08/31,10:05:13) */
  1076. /*% cc -O -c %
  1077.  *
  1078.  */
  1079.  
  1080. #include <stdio.h>
  1081. #include "defs.h"
  1082. #include "data.h"
  1083.  
  1084. /*    Define ASNM and LDNM to the names of the assembler and linker
  1085.     respectively */
  1086.  
  1087. /*
  1088.  *    Some predefinitions:
  1089.  *
  1090.  *    INTSIZE is the size of an integer in the target machine
  1091.  *    BYTEOFF is the offset of an byte within an integer on the
  1092.  *        target machine. (ie: 8080,pdp11 = 0, 6809 = 1,
  1093.  *        360 = 3)
  1094.  *    This compiler assumes that an integer is the SAME length as
  1095.  *    a pointer - in fact, the compiler uses INTSIZE for both.
  1096.  */
  1097. #define    INTSIZE    2
  1098. #define    BYTEOFF    1
  1099.  
  1100. /*
  1101.  *    print all assembler info before any code is generated
  1102.  *
  1103.  */
  1104. header ()
  1105. {
  1106.     outstr("|\tSmall C MC6809\n|\tCoder (2.4,84/11/27)\n|");
  1107.     FEvers();
  1108.     nl ();
  1109.     ol (".globl\tsmul,sdiv,smod,asr,asl,neg,lneg,case");
  1110.     ol (".globl\teq,ne,lt,le,gt,ge,ult,ule,ugt,uge,bool");
  1111. }
  1112. nl ()
  1113. {
  1114.     outbyte (EOL);
  1115. }
  1116.  
  1117. initmac() {
  1118.     defmac("mc6809\t1");
  1119.     defmac("mitas09\t1");
  1120.     defmac("smallc\t1");
  1121. }
  1122.  
  1123. galign(t)
  1124. int t;
  1125. {
  1126.     return (t);
  1127. }
  1128.  
  1129.  
  1130. /*
  1131.  *    return size of an integer
  1132.  */
  1133. intsize() {
  1134.     return(INTSIZE);
  1135. }
  1136.  
  1137. /*
  1138.  *    return offset of ls byte within word
  1139.  *    (ie: 8080 & pdp11 is 0, 6809 is 1, 360 is 3)
  1140.  */
  1141. byteoff() {
  1142.     return(BYTEOFF);
  1143. }
  1144.  
  1145. /*
  1146.  *    Output internal generated label prefix
  1147.  */
  1148. olprfix() {
  1149.     outstr("LL");
  1150. }
  1151.  
  1152. /*
  1153.  *    Output a label definition terminator
  1154.  */
  1155. col ()
  1156. {
  1157.     outstr ("=.\n");
  1158. }
  1159.  
  1160. /*
  1161.  *    begin a comment line for the assembler
  1162.  *
  1163.  */
  1164. comment ()
  1165. {
  1166.     outbyte ('|');
  1167. }
  1168.  
  1169. /*
  1170.  *    Output a prefix in front of user labels
  1171.  */
  1172. prefix () {
  1173.     outbyte ('_');
  1174. }
  1175.  
  1176.  
  1177. /*
  1178.  *    print any assembler stuff needed after all code
  1179.  *
  1180.  */
  1181. trailer ()
  1182. {
  1183.     ol (".end");
  1184. }
  1185.  
  1186. /*
  1187.  *    function prologue
  1188.  */
  1189. prologue ()
  1190. {
  1191. }
  1192.  
  1193. /*
  1194.  *    text (code) segment
  1195.  */
  1196. gtext ()
  1197. {
  1198.     ol (".text");
  1199. }
  1200.  
  1201. /*
  1202.  *    data segment
  1203.  */
  1204. gdata ()
  1205. {
  1206.     ol (".data");
  1207. }
  1208.  
  1209. /*
  1210.  *  Output the variable symbol at scptr as an extrn or a public
  1211.  */
  1212. ppubext(scptr) char *scptr; {
  1213.     if (scptr[STORAGE] == STATIC) return;
  1214.     ot (".globl\t");
  1215.     prefix ();
  1216.     outstr (scptr);
  1217.     nl();
  1218. }
  1219.  
  1220. /*
  1221.  * Output the function symbol at scptr as an extrn or a public
  1222.  */
  1223. fpubext(scptr) char *scptr; {
  1224.     ppubext(scptr);
  1225. }
  1226.  
  1227. /*
  1228.  *  Output a decimal number to the assembler file
  1229.  */
  1230. onum(num) int num; {
  1231.     outdec(num);    /* pdp11 needs a "." here */
  1232.     outbyte('.');
  1233. }
  1234.  
  1235.  
  1236. /*
  1237.  *    fetch a static memory cell into the primary register
  1238.  */
  1239. getmem (sym)
  1240. char    *sym;
  1241. {
  1242.     if ((sym[IDENT] != POINTER) & (sym[TYPE] == CCHAR)) {
  1243.         ot ("ldb\t");
  1244.         prefix ();
  1245.         outstr (sym + NAME);
  1246.         nl ();
  1247.         ot ("sex");
  1248.         nl ();
  1249.     } else {
  1250.         ot ("ldd\t");
  1251.         prefix ();
  1252.         outstr (sym + NAME);
  1253.         nl ();
  1254.     }
  1255. }
  1256.  
  1257. /*
  1258.  *    fetch the address of the specified symbol into the primary register
  1259.  *
  1260.  */
  1261. getloc (sym)
  1262. char    *sym;
  1263. {
  1264.     if (sym[STORAGE] == LSTATIC) {
  1265.         immed();
  1266.         printlabel(glint(sym));
  1267.         nl();
  1268.     } else {
  1269.         ot ("leay\t");
  1270.         onum (glint(sym) - stkp);
  1271.         outstr ("(s)\n\ttfr\ty,d\n");
  1272.     }
  1273. }
  1274.  
  1275. /*
  1276.  *    store the primary register into the specified static memory cell
  1277.  *
  1278.  */
  1279. putmem (sym)
  1280. char    *sym;
  1281. {
  1282.     if ((sym[IDENT] != POINTER) & (sym[TYPE] == CCHAR)) {
  1283.         ot ("stb\t");
  1284.     } else
  1285.         ot ("std\t");
  1286.     prefix ();
  1287.     outstr (sym + NAME);
  1288.     nl ();
  1289. }
  1290.  
  1291. /*
  1292.  *    store the specified object type in the primary register
  1293.  *    at the address on the top of the stack
  1294.  *
  1295.  */
  1296. putstk (typeobj)
  1297. char    typeobj;
  1298. {
  1299.     if (typeobj == CCHAR)
  1300.         ol ("stb\t@(s)++");
  1301.     else
  1302.         ol ("std\t@(s)++");
  1303.     stkp = stkp + INTSIZE;
  1304. }
  1305.  
  1306. /*
  1307.  *    fetch the specified object type indirect through the primary
  1308.  *    register into the primary register
  1309.  *
  1310.  */
  1311. indirect (typeobj)
  1312. char    typeobj;
  1313. {
  1314.     ol("tfr\td,y");
  1315.     if (typeobj == CCHAR)
  1316.         ol ("ldb\t(y)\n\tsex");
  1317.     else
  1318.         ol ("ldd\t(y)");
  1319. }
  1320.  
  1321. /*
  1322.  *    swap the primary and secondary registers
  1323.  *
  1324.  */
  1325. swap ()
  1326. {
  1327.     ol ("exg\td,x");
  1328. }
  1329.  
  1330. /*
  1331.  *    print partial instruction to get an immediate value into
  1332.  *    the primary register
  1333.  *
  1334.  */
  1335. immed ()
  1336. {
  1337.     ot ("ldd\t#");
  1338. }
  1339.  
  1340. /*
  1341.  *    push the primary register onto the stack
  1342.  *
  1343.  */
  1344. gpush ()
  1345. {
  1346.     ol ("pshs\td");
  1347.     stkp = stkp - INTSIZE;
  1348. }
  1349.  
  1350. /*
  1351.  *    pop the top of the stack into the secondary register
  1352.  *
  1353.  */
  1354. gpop ()
  1355. {
  1356.     ol ("puls\td");
  1357.     stkp = stkp + INTSIZE;
  1358. }
  1359.  
  1360. /*
  1361.  *    swap the primary register and the top of the stack
  1362.  *
  1363.  */
  1364. swapstk ()
  1365. {
  1366.     ol ("ldy\t(s)\nstd\t(s)\n\ttfr\ty,d");
  1367. }
  1368.  
  1369. /*
  1370.  *    call the specified subroutine name
  1371.  *
  1372.  */
  1373. gcall (sname)
  1374. char    *sname;
  1375. {
  1376.     ot ("jsr\t");
  1377.     if (*sname == '^')
  1378.         outstr (++sname);
  1379.     else {
  1380.         prefix ();
  1381.         outstr (sname);
  1382.     }
  1383.     nl ();
  1384. }
  1385.  
  1386. /*
  1387.  *    return from subroutine
  1388.  *
  1389.  */
  1390. gret ()
  1391. {
  1392.     ol ("rts");
  1393. }
  1394.  
  1395. /*
  1396.  *    perform subroutine call to value on top of stack
  1397.  *
  1398.  */
  1399. callstk ()
  1400. {
  1401.     gpop();
  1402.     ol ("jsr\t(x)");
  1403. }
  1404.  
  1405. /*
  1406.  *    jump to specified internal label number
  1407.  *
  1408.  */
  1409. jump (label)
  1410. int    label;
  1411. {
  1412.     ot ("lbra\t");
  1413.     printlabel (label);
  1414.     nl ();
  1415. }
  1416.  
  1417. /*
  1418.  *    test the primary register and jump if false to label
  1419.  *
  1420.  */
  1421. testjump (label, ft)
  1422. int    label,
  1423.     ft;
  1424. {
  1425.     ol ("cmpd\t#0");
  1426.     if (ft)
  1427.         ot ("lbne\t");
  1428.     else
  1429.         ot ("lbeq\t");
  1430.     printlabel (label);
  1431.     nl ();
  1432. }
  1433.  
  1434. /*
  1435.  *    print pseudo-op  to define a byte
  1436.  *
  1437.  */
  1438. defbyte ()
  1439. {
  1440.     ot (".byte\t");
  1441. }
  1442.  
  1443. /*
  1444.  *    print pseudo-op to define storage
  1445.  *
  1446.  */
  1447. defstorage ()
  1448. {
  1449.     ot (".blkb\t");
  1450. }
  1451.  
  1452. /*
  1453.  *    print pseudo-op to define a word
  1454.  *
  1455.  */
  1456. defword ()
  1457. {
  1458.     ot (".word\t");
  1459. }
  1460.  
  1461. /*
  1462.  *    modify the stack pointer to the new value indicated
  1463.  *
  1464.  */
  1465. modstk (newstkp)
  1466. int    newstkp;
  1467. {
  1468.     int    k;
  1469.  
  1470.     k = galign(newstkp - stkp);
  1471.     if (k == 0)
  1472.         return (newstkp);
  1473.     ot ("leas\t");
  1474.     onum (k);
  1475.     outstr ("(s)\n");
  1476.     return (newstkp);
  1477. }
  1478.  
  1479. /*
  1480.  *    multiply the primary register by INTSIZE
  1481.  */
  1482. gaslint ()
  1483. {
  1484.     ol ("aslb\n\trola");
  1485. }
  1486.  
  1487. /*
  1488.  *    divide the primary register by INTSIZE
  1489.  */
  1490. gasrint()
  1491. {
  1492.     ol ("asra\n\trorb");
  1493. }
  1494.  
  1495. /*
  1496.  *    Case jump instruction
  1497.  */
  1498. gjcase() {
  1499.     ot ("jmp\tcase");
  1500.     nl ();
  1501. }
  1502.  
  1503. /*
  1504.  *    add the primary and secondary registers
  1505.  *    if lval2 is int pointer and lval is int, scale lval
  1506.  */
  1507. gadd (lval, lval2) int *lval, *lval2;
  1508. {
  1509.     if (dbltest (lval2, lval)) {
  1510.         ol ("asl\t1(s)\n\trol\t(s)");
  1511.     }
  1512.     ol ("addd\t(s)++");
  1513.     stkp = stkp + INTSIZE;
  1514. }
  1515.  
  1516. /*
  1517.  *    subtract the primary register from the secondary
  1518.  *
  1519.  */
  1520. gsub ()
  1521. {
  1522.     ol ("subd\t(s)++\n\tcoma\n\tcomb\n\taddd\t#1");
  1523.     stkp = stkp + INTSIZE;
  1524. }
  1525.  
  1526. /*
  1527.  *    multiply the primary and secondary registers
  1528.  *    (result in primary)
  1529.  *
  1530.  */
  1531. gmult ()
  1532. {
  1533.     gcall ("^smul");
  1534.     stkp = stkp + INTSIZE;
  1535. }
  1536.  
  1537. /*
  1538.  *    divide the secondary register by the primary
  1539.  *    (quotient in primary, remainder in secondary)
  1540.  *
  1541.  */
  1542. gdiv ()
  1543. {
  1544.     gcall ("^sdiv");
  1545.     stkp = stkp + INTSIZE;
  1546. }
  1547.  
  1548. /*
  1549.  *    compute the remainder (mod) of the secondary register
  1550.  *    divided by the primary register
  1551.  *    (remainder in primary, quotient in secondary)
  1552.  *
  1553.  */
  1554. gmod ()
  1555. {
  1556.     gcall ("^smod");
  1557.     stkp = stkp + INTSIZE;
  1558. }
  1559.  
  1560. /*
  1561.  *    inclusive 'or' the primary and secondary registers
  1562.  *
  1563.  */
  1564. gor ()
  1565. {
  1566.     ol ("ora\t(s)+\n\torb\t(s)+");
  1567.     stkp = stkp + INTSIZE;
  1568. }
  1569.  
  1570. /*
  1571.  *    exclusive 'or' the primary and secondary registers
  1572.  *
  1573.  */
  1574. gxor ()
  1575. {
  1576.     ol ("eora\t(s)+\n\teorb\t(s)+");
  1577.     stkp = stkp + INTSIZE;
  1578. }
  1579.  
  1580. /*
  1581.  *    'and' the primary and secondary registers
  1582.  *
  1583.  */
  1584. gand ()
  1585. {
  1586.     ol ("anda\t(s)+\n\tandb\t(s)+");
  1587.     stkp = stkp + INTSIZE;
  1588. }
  1589.  
  1590. /*
  1591.  *    arithmetic shift right the secondary register the number of
  1592.  *    times in the primary register
  1593.  *    (results in primary register)
  1594.  *
  1595.  */
  1596. gasr ()
  1597. {
  1598.     gcall ("^asr");
  1599.     stkp = stkp + INTSIZE;
  1600. }
  1601.  
  1602. /*
  1603.  *    arithmetic shift left the secondary register the number of
  1604.  *    times in the primary register
  1605.  *    (results in primary register)
  1606.  *
  1607.  */
  1608. gasl ()
  1609. {
  1610.     gcall ("^asl");
  1611.     stkp = stkp + INTSIZE;
  1612. }
  1613.  
  1614. /*
  1615.  *    two's complement of primary register
  1616.  *
  1617.  */
  1618. gneg ()
  1619. {
  1620.     gcall ("^neg");
  1621. }
  1622.  
  1623. /*
  1624.  *    logical complement of primary register
  1625.  *
  1626.  */
  1627. glneg ()
  1628. {
  1629.     gcall ("^lneg");
  1630. }
  1631.  
  1632. /*
  1633.  *    one's complement of primary register
  1634.  *
  1635.  */
  1636. gcom ()
  1637. {
  1638.     ol ("coma\n\tcomb");
  1639. }
  1640.  
  1641. /*
  1642.  *    convert primary register into logical value
  1643.  *
  1644.  */
  1645. gbool ()
  1646. {
  1647.     gcall ("^bool");
  1648. }
  1649. /*
  1650.  *    increment the primary register by 1 if char, INTSIZE if
  1651.  *      int
  1652.  */
  1653. ginc (lval) int lval[];
  1654. {
  1655.     if (lval[2] == CINT)
  1656.         ol ("addd\t#2");
  1657.     else
  1658.         ol ("addd\t#1");
  1659. }
  1660.  
  1661. /*
  1662.  *    decrement the primary register by one if char, INTSIZE if
  1663.  *    int
  1664.  */
  1665. gdec (lval) int lval[];
  1666. {
  1667.     if (lval[2] == CINT)
  1668.         ol ("subd\t#2");
  1669.     else
  1670.         ol ("subd\t#1");
  1671. }
  1672.  
  1673. /*
  1674.  *    following are the conditional operators.
  1675.  *    they compare the secondary register against the primary register
  1676.  *    and put a literl 1 in the primary if the condition is true,
  1677.  *    otherwise they clear the primary register
  1678.  *
  1679.  */
  1680.  
  1681. /*
  1682.  *    equal
  1683.  *
  1684.  */
  1685. geq ()
  1686. {
  1687.     gcall ("^eq");
  1688.     stkp = stkp + INTSIZE;
  1689. }
  1690.  
  1691. /*
  1692.  *    not equal
  1693.  *
  1694.  */
  1695. gne ()
  1696. {
  1697.     gcall ("^ne");
  1698.     stkp = stkp + INTSIZE;
  1699. }
  1700.  
  1701. /*
  1702.  *    less than (signed)
  1703.  *
  1704.  */
  1705. glt ()
  1706. {
  1707.     gcall ("^lt");
  1708.     stkp = stkp + INTSIZE;
  1709. }
  1710. /*
  1711.  *    less than or equal (signed)
  1712.  *
  1713.  */
  1714. gle ()
  1715. {
  1716.     gcall ("^le");
  1717.     stkp = stkp + INTSIZE;
  1718. }
  1719.  
  1720. /*
  1721.  *    greater than (signed)
  1722.  *
  1723.  */
  1724. ggt ()
  1725. {
  1726.     gcall ("^gt");
  1727.     stkp = stkp + INTSIZE;
  1728. }
  1729.  
  1730. /*
  1731.  *    greater than or equal (signed)
  1732.  *
  1733.  */
  1734. gge ()
  1735. {
  1736.     gcall ("^ge");
  1737.     stkp = stkp + INTSIZE;
  1738. }
  1739.  
  1740. /*
  1741.  *    less than (unsigned)
  1742.  *
  1743.  */
  1744. gult ()
  1745. {
  1746.     gcall ("^ult");
  1747.     stkp = stkp + INTSIZE;
  1748. }
  1749.  
  1750. /*
  1751.  *    less than or equal (unsigned)
  1752.  *
  1753.  */
  1754. gule ()
  1755. {
  1756.     gcall ("^ule");
  1757.     stkp = stkp + INTSIZE;
  1758. }
  1759.  
  1760. /*
  1761.  *    greater than (unsigned)
  1762.  *
  1763.  */
  1764. gugt ()
  1765. {
  1766.     gcall ("^ugt");
  1767.     stkp = stkp + INTSIZE;
  1768. }
  1769.  
  1770. /*
  1771.  *    greater than or equal (unsigned)
  1772.  *
  1773.  */
  1774. guge ()
  1775. {
  1776.     gcall ("^uge");
  1777.     stkp = stkp + INTSIZE;
  1778. }
  1779.  
  1780. inclib() {
  1781. #ifdef    flex
  1782.     return("B.");
  1783. #endif
  1784. #ifdef    unix
  1785.     return(INCDIR);
  1786. #endif
  1787. #ifdef    cpm
  1788.     return("B:");
  1789. #endif
  1790. }
  1791.  
  1792. /*    Squirrel away argument count in a register that modstk/getloc/stloc
  1793.     doesn't touch.
  1794. */
  1795.  
  1796. gnargs(d)
  1797. int    d; {
  1798.     ot ("ldu\t#");
  1799.     onum(d);
  1800.     nl ();
  1801. }
  1802.  
  1803. assemble(s)
  1804. char    *s; {
  1805. #ifdef    ASNM
  1806.     char buf[100];
  1807.     strcpy(buf, ASNM);
  1808.     strcat(buf, " ");
  1809.     strcat(buf, s);
  1810.     buf[strlen(buf)-1] = 's';
  1811.     return(system(buf));
  1812. #else
  1813.     return(0);
  1814. #endif
  1815. }
  1816.  
  1817. link() {
  1818. #ifdef    LDNM
  1819.     fputs("I don't know how to link files yet\n", stderr);
  1820. #else
  1821.     return(0);
  1822. #endif
  1823. }
  1824. SHAR_EOF
  1825. if test 9534 -ne "`wc -c < 'codeas09.c'`"
  1826. then
  1827.     echo shar: error transmitting "'codeas09.c'" '(should have been 9534 characters)'
  1828. fi
  1829. fi
  1830. echo shar: extracting "'codem68k.c'" '(11259 characters)'
  1831. if test -f 'codem68k.c'
  1832. then
  1833.     echo shar: will not over-write existing file "'codem68k.c'"
  1834. else
  1835. cat << \SHAR_EOF > 'codem68k.c'
  1836. /*    File codem68k.c: 1.2 (84/11/28,10:15:09) */
  1837. /*% cc -O -c %
  1838.  *
  1839.  */
  1840.  
  1841. #include <stdio.h>
  1842. #include "defs.h"
  1843. #include "data.h"
  1844.  
  1845. #ifdef    unix
  1846. #ifdef    m68k
  1847. #define    ASNM    "as -o "
  1848. #define    LDNM    "ld -o a.out /lib/crt0.o "
  1849. #endif
  1850. #ifdef    pyr
  1851. #define    ASNM    "/u1/cx/bin/m68kas -o "
  1852. #define    LDNM    "/u1/cx/bin/m68kld -o a.out /u1/cx/lib/m68kcrt0.o "
  1853. #endif
  1854. #endif
  1855.  
  1856. int    needr0;
  1857. int    needh;
  1858. /*
  1859.  *    Some predefinitions:
  1860.  *
  1861.  *    INTSIZE is the size of an integer in the target machine
  1862.  *    BYTEOFF is the offset of an byte within an integer on the
  1863.  *        target machine. (ie: 8080,pdp11 = 0, 6809 = 1,
  1864.  *        360 = 3)
  1865.  *    This compiler assumes that an integer is the SAME length as
  1866.  *    a pointer - in fact, the compiler uses INTSIZE for both.
  1867.  */
  1868. #define    INTSIZE    4
  1869. #define    BYTEOFF    3
  1870.  
  1871. /*
  1872.  *    print all assembler info before any code is generated
  1873.  *
  1874.  */
  1875. header ()
  1876. {
  1877.     outstr("#\tSmall C M68000\n#\tCoder (1.2,84/11/28)\n#");
  1878.     FEvers();
  1879.     nl ();
  1880.     ol ("global\tTlneg");
  1881.     ol ("global\tTcase");
  1882.     ol ("global\tTeq");
  1883.     ol ("global\tTne");
  1884.     ol ("global\tTlt");
  1885.     ol ("global\tTle");
  1886.     ol ("global\tTgt");
  1887.     ol ("global\tTge");
  1888.     ol ("global\tTult");
  1889.     ol ("global\tTule");
  1890.     ol ("global\tTugt");
  1891.     ol ("global\tTuge");
  1892.     ol ("global\tTbool");
  1893.     ol ("global\tTmult");
  1894.     ol ("global\tTdiv");
  1895.     ol ("global\tTmod");
  1896. }
  1897.  
  1898. nl()
  1899. {
  1900.     if (needh) {
  1901.         ol ("word\t0");
  1902.         needh = 0;
  1903.     }
  1904.     if (needr0) {
  1905.         needr0 = 0;
  1906.         outstr(",%d0");
  1907.     }
  1908.     outbyte(EOL);
  1909. }
  1910.  
  1911. initmac() {
  1912.     defmac("m68k\t1");
  1913.     defmac("unix\t1");
  1914.     defmac("smallc\t1");
  1915. }
  1916.  
  1917. galign(t)
  1918. int t;
  1919. {
  1920.     int sign;
  1921.     if (t < 0) {
  1922.         sign = 1;
  1923.         t = -t;
  1924.     } else
  1925.         sign = 0;
  1926.     t = (t + INTSIZE - 1) & ~(INTSIZE - 1);
  1927.     t = sign? -t: t;
  1928.     return (t);
  1929. }
  1930.  
  1931.  
  1932.  
  1933. /*
  1934.  *    return size of an integer
  1935.  */
  1936. intsize() {
  1937.     return(INTSIZE);
  1938. }
  1939.  
  1940. /*
  1941.  *    return offset of ls byte within word
  1942.  *    (ie: 8080 & pdp11 is 0, 6809 is 1, 360 is 3)
  1943.  */
  1944. byteoff() {
  1945.     return(BYTEOFF);
  1946. }
  1947.  
  1948. /*
  1949.  *    Output internal generated label prefix
  1950.  */
  1951. olprfix() {
  1952.     outstr("LL");
  1953. }
  1954.  
  1955. /*
  1956.  *    Output a label definition terminator
  1957.  */
  1958. col ()
  1959. {
  1960.     outstr (":\n");
  1961. }
  1962.  
  1963. /*
  1964.  *    begin a comment line for the assembler
  1965.  *
  1966.  */
  1967. comment ()
  1968. {
  1969.     outbyte ('#');
  1970. }
  1971.  
  1972. /*
  1973.  *    Output a prefix in front of user labels
  1974.  */
  1975. prefix () {
  1976. /*    outbyte ('_'); */
  1977. }
  1978.  
  1979.  
  1980. /*
  1981.  *    print any assembler stuff needed after all code
  1982.  *
  1983.  */
  1984. trailer ()
  1985. {
  1986. }
  1987.  
  1988. /*
  1989.  *    function prologue
  1990.  */
  1991. prologue ()
  1992. {
  1993.     /* this is where we'd put splimit stuff */
  1994. }
  1995.  
  1996. /*
  1997.  *    text (code) segment
  1998.  */
  1999. gtext ()
  2000. {
  2001.     ol ("text");
  2002. }
  2003.  
  2004. /*
  2005.  *    data segment
  2006.  */
  2007. gdata ()
  2008. {
  2009.     ol ("data");
  2010. }
  2011.  
  2012. /*
  2013.  *  Output the variable symbol at scptr as an extrn or a public
  2014.  */
  2015. ppubext(scptr) char *scptr; {
  2016.     if (scptr[STORAGE] == STATIC) return;
  2017.     ot ("global\t");
  2018.     prefix ();
  2019.     outstr (scptr);
  2020.     nl();
  2021. }
  2022.  
  2023. /*
  2024.  * Output the function symbol at scptr as an extrn or a public
  2025.  */
  2026. fpubext(scptr) char *scptr; {
  2027.     ppubext(scptr);
  2028. }
  2029.  
  2030. /*
  2031.  *  Output a decimal number to the assembler file
  2032.  */
  2033. onum(num) int num; {
  2034.     outdec(num);    /* pdp11 needs a "." here */
  2035. }
  2036.  
  2037.  
  2038. /*
  2039.  *    fetch a static memory cell into the primary register
  2040.  */
  2041. getmem (sym)
  2042. char    *sym;
  2043. {
  2044.     int ischr;
  2045.     if ((sym[IDENT] != POINTER) & (sym[TYPE] == CCHAR)) {
  2046.         ischr = 1;
  2047.         ot ("mov.b\t");
  2048.         prefix ();
  2049.         outstr (sym + NAME);
  2050.     } else {
  2051.         ischr = 0;
  2052.         ot ("mov.l\t");
  2053.         prefix ();
  2054.         outstr (sym + NAME);
  2055.     }
  2056.     outstr(",%d0\n");
  2057.     if (ischr)
  2058.         ol ("ext.b\t%d0");
  2059. }
  2060.  
  2061. /*
  2062.  *    fetch the address of the specified symbol into the primary register
  2063.  *
  2064.  */
  2065. getloc (sym)
  2066. char    *sym;
  2067. {
  2068.     if (sym[STORAGE] == LSTATIC) {
  2069.         immed();
  2070.         printlabel(glint(sym));
  2071.         nl();
  2072.     } else {
  2073.         ot ("lea.l\t");
  2074.         onum (glint(sym) - stkp);
  2075.         outstr (",%a0\n");
  2076.         ol ("mov.l\t%a0,%d0");
  2077.     }
  2078. }
  2079.  
  2080. /*
  2081.  *    store the primary register into the specified static memory cell
  2082.  *
  2083.  */
  2084. putmem (sym)
  2085. char    *sym;
  2086. {
  2087.     if ((sym[IDENT] != POINTER) & (sym[TYPE] == CCHAR)) {
  2088.         ot ("mov.b\t%d0,");
  2089.     } else
  2090.         ot ("mov.l\t%d0,");
  2091.     prefix ();
  2092.     outstr (sym + NAME);
  2093.     nl ();
  2094. }
  2095.  
  2096. /*
  2097.  *    store the specified object type in the primary register
  2098.  *    at the address on the top of the stack
  2099.  *
  2100.  */
  2101. putstk (typeobj)
  2102. char    typeobj;
  2103. {
  2104.     ol ("mov.l\t(%sp)+,%a0");
  2105.     if (typeobj == CCHAR)
  2106.         ol ("mov.b\t%d0,(%a0)");
  2107.     else
  2108.         ol ("mov.l\t%d0,(%a0)");
  2109.     stkp = stkp + INTSIZE;
  2110. }
  2111.  
  2112. /*
  2113.  *    fetch the specified object type indirect through the primary
  2114.  *    register into the primary register
  2115.  *
  2116.  */
  2117. indirect (typeobj)
  2118. char    typeobj;
  2119. {
  2120.     ol ("mov.l\t%d0,%a0");
  2121.     if (typeobj == CCHAR)
  2122.         ol ("mov.b\t(%a0),%d0");
  2123.     else
  2124.         ol ("mov.l\t(%a0),%d0");
  2125. }
  2126.  
  2127. /*
  2128.  *    swap the primary and secondary registers
  2129.  *
  2130.  */
  2131. swap ()
  2132. {
  2133.     ol ("mov.l\t%d0,%d2\n\tmov.l\t%d1,%d0\n\tmov.l\t%d2,%d1");
  2134. }
  2135.  
  2136. /*
  2137.  *    print partial instruction to get an immediate value into
  2138.  *    the primary register
  2139.  *
  2140.  */
  2141. immed ()
  2142. {
  2143.     ot ("mov.l\t&");
  2144.     needr0 = 1;
  2145. }
  2146.  
  2147. /*
  2148.  *    push the primary register onto the stack
  2149.  *
  2150.  */
  2151. gpush ()
  2152. {
  2153.     ol ("mov.l\t%d0,-(%sp)");
  2154.     stkp = stkp - INTSIZE;
  2155. }
  2156.  
  2157. /*
  2158.  *    pop the top of the stack into the secondary register
  2159.  *
  2160.  */
  2161. gpop ()
  2162. {
  2163.     ol ("mov.l\t(%sp)+,%d1");
  2164.     stkp = stkp + INTSIZE;
  2165. }
  2166.  
  2167. /*
  2168.  *    swap the primary register and the top of the stack
  2169.  *
  2170.  */
  2171. swapstk ()
  2172. {
  2173.     ol ("mov.l\t(%sp)+,%d2\nmov.l\t%d0,-(%sp)\nmov.l\t%d2,%d0");
  2174. }
  2175.  
  2176. /*
  2177.  *    call the specified subroutine name
  2178.  *
  2179.  */
  2180. gcall (sname)
  2181. char    *sname;
  2182. {
  2183.     if (*sname == '^') {
  2184.         ot ("jsr\tT");
  2185.         outstr (++sname);
  2186.     } else {
  2187.         ot ("jsr\t");
  2188.         prefix ();
  2189.         outstr (sname);
  2190.     }
  2191.     nl ();
  2192. }
  2193.  
  2194. /*
  2195.  *    return from subroutine
  2196.  *
  2197.  */
  2198. gret ()
  2199. {
  2200.     ol ("rts");
  2201. }
  2202.  
  2203. /*
  2204.  *    perform subroutine call to value on top of stack
  2205.  *
  2206.  */
  2207. callstk ()
  2208. {
  2209.     ol ("jsr\t(%sp)+");
  2210.     stkp = stkp + INTSIZE;
  2211. }
  2212.  
  2213. /*
  2214.  *    jump to specified internal label number
  2215.  *
  2216.  */
  2217. jump (label)
  2218. int    label;
  2219. {
  2220.     ot ("jmp\t");
  2221.     printlabel (label);
  2222.     nl ();
  2223. }
  2224.  
  2225. /*
  2226.  *    test the primary register and jump if false to label
  2227.  *
  2228.  */
  2229. testjump (label, ft)
  2230. int    label,
  2231.     ft;
  2232. {
  2233.     ol ("cmp.l\t%d0,&0");
  2234.     if (ft)
  2235.         ot ("beq\t");
  2236.     else
  2237.         ot ("bne\t");
  2238.     printlabel (label);
  2239.     nl ();
  2240. }
  2241.  
  2242. /*
  2243.  *    print pseudo-op  to define a byte
  2244.  *
  2245.  */
  2246. defbyte ()
  2247. {
  2248.     ot ("byte\t");
  2249. }
  2250.  
  2251. /*
  2252.  *    print pseudo-op to define storage
  2253.  *
  2254.  */
  2255. defstorage ()
  2256. {
  2257.     ot ("space\t");
  2258. }
  2259.  
  2260. /*
  2261.  *    print pseudo-op to define a word
  2262.  *
  2263.  */
  2264. defword ()
  2265. {
  2266.     ot ("long\t");
  2267. }
  2268.  
  2269. /*
  2270.  *    modify the stack pointer to the new value indicated
  2271.  *
  2272.  */
  2273. modstk (newstkp)
  2274. int    newstkp;
  2275. {
  2276.     int    k;
  2277.  
  2278.     k = newstkp - stkp;
  2279.     if (k % INTSIZE)
  2280.         error("Bad stack alignment (compiler error)");
  2281.     if (k == 0)
  2282.         return (newstkp);
  2283.     ot ("add.l\t&");
  2284.     onum (k);
  2285.     outstr (",sp");
  2286.     nl();
  2287.     return (newstkp);
  2288. }
  2289.  
  2290. /*
  2291.  *    multiply the primary register by INTSIZE
  2292.  */
  2293. gaslint ()
  2294. {
  2295.     ol ("asl.l\t&2,%d0");
  2296. }
  2297.  
  2298. /*
  2299.  *    divide the primary register by INTSIZE
  2300.  */
  2301. gasrint()
  2302. {
  2303.     ol ("asr.l\t&2,%d0");
  2304. }
  2305.  
  2306. /*
  2307.  *    Case jump instruction
  2308.  */
  2309. gjcase() {
  2310.     gcall ("^case");
  2311. }
  2312.  
  2313. /*
  2314.  *    add the primary and secondary registers
  2315.  *    if lval2 is int pointer and lval is int, scale lval
  2316.  */
  2317. gadd (lval, lval2) int *lval, *lval2;
  2318. {
  2319.     if (dbltest (lval2, lval)) {
  2320.         ol ("asl.l\t&2,(%sp)");
  2321.     }
  2322.     ol ("add.l\t(%sp)+,%d0");
  2323.     stkp = stkp + INTSIZE;
  2324. }
  2325.  
  2326. /*
  2327.  *    subtract the primary register from the secondary
  2328.  *
  2329.  */
  2330. gsub ()
  2331. {
  2332.     ol ("mov.l\t(%sp)+,%d2");
  2333.     ol ("sub.l\t%d0,%d2");
  2334.     ol ("mov.l\t%d2,%d0");
  2335.     stkp = stkp + INTSIZE;
  2336. }
  2337.  
  2338. /*
  2339.  *    multiply the primary and secondary registers
  2340.  *    (result in primary)
  2341.  *
  2342.  */
  2343. gmult ()
  2344. {
  2345.     gcall ("^mult");
  2346.     stkp = stkp + INTSIZE;
  2347. }
  2348.  
  2349. /*
  2350.  *    divide the secondary register by the primary
  2351.  *    (quotient in primary, remainder in secondary)
  2352.  *
  2353.  */
  2354. gdiv ()
  2355. {
  2356.     gcall ("^div");
  2357.     stkp = stkp + INTSIZE;
  2358. }
  2359.  
  2360. /*
  2361.  *    compute the remainder (mod) of the secondary register
  2362.  *    divided by the primary register
  2363.  *    (remainder in primary, quotient in secondary)
  2364.  *
  2365.  */
  2366. gmod ()
  2367. {
  2368.     gcall ("^mod");
  2369.     stkp = stkp + INTSIZE;
  2370. }
  2371.  
  2372. /*
  2373.  *    inclusive 'or' the primary and secondary registers
  2374.  *
  2375.  */
  2376. gor ()
  2377. {
  2378.     ol ("or.l\t(%sp)+,%d0");
  2379.     stkp = stkp + INTSIZE;
  2380. }
  2381.  
  2382. /*
  2383.  *    exclusive 'or' the primary and secondary registers
  2384.  *
  2385.  */
  2386. gxor ()
  2387. {
  2388.     ol ("mov.l\t(%sp)+,%d1");
  2389.     ol ("eor.l\t%d1,%d0");
  2390.     stkp = stkp + INTSIZE;
  2391. }
  2392.  
  2393. /*
  2394.  *    'and' the primary and secondary registers
  2395.  *
  2396.  */
  2397. gand ()
  2398. {
  2399.     ol ("and.l\t(%sp)+,%d0");
  2400.     stkp = stkp + INTSIZE;
  2401. }
  2402.  
  2403. /*
  2404.  *    arithmetic shift right the secondary register the number of
  2405.  *    times in the primary register
  2406.  *    (results in primary register)
  2407.  *
  2408.  */
  2409. gasr ()
  2410. {
  2411.     ol ("mov.l\t(%sp)+,%d1");
  2412.     ol ("asr.l\t%d0,%d1");
  2413.     ol ("mov.l\t%d1,%d0");
  2414.     stkp = stkp + INTSIZE;
  2415. }
  2416.  
  2417. /*
  2418.  *    arithmetic shift left the secondary register the number of
  2419.  *    times in the primary register
  2420.  *    (results in primary register)
  2421.  *
  2422.  */
  2423. gasl ()
  2424. {
  2425.     ol ("mov.l\t(%sp)+,%d1");
  2426.     ol ("asl.l\t%d0,%d1");
  2427.     ol ("mov.l\t%d1,%d0");
  2428.     stkp = stkp + INTSIZE;
  2429. }
  2430.  
  2431. /*
  2432.  *    two's complement of primary register
  2433.  *
  2434.  */
  2435. gneg ()
  2436. {
  2437.     ol ("neg.l\t%d0");
  2438. }
  2439.  
  2440. /*
  2441.  *    logical complement of primary register
  2442.  *
  2443.  */
  2444. glneg ()
  2445. {
  2446.     gcall ("^lneg");
  2447. }
  2448.  
  2449. /*
  2450.  *    one's complement of primary register
  2451.  *
  2452.  */
  2453. gcom ()
  2454. {
  2455.     ol ("not\t%d0");
  2456. }
  2457.  
  2458. /*
  2459.  *    convert primary register into logical value
  2460.  *
  2461.  */
  2462. gbool ()
  2463. {
  2464.     gcall ("^bool");
  2465. }
  2466. /*
  2467.  *    increment the primary register by 1 if char, INTSIZE if
  2468.  *      int
  2469.  */
  2470. ginc (lval) int lval[];
  2471. {
  2472.     if (lval[2] == CINT)
  2473.         ol ("addq.l\t&4,%d0");
  2474.     else
  2475.         ol ("addq.l\t&1,%d0");
  2476. }
  2477.  
  2478. /*
  2479.  *    decrement the primary register by one if char, INTSIZE if
  2480.  *    int
  2481.  */
  2482. gdec (lval) int lval[];
  2483. {
  2484.     if (lval[2] == CINT)
  2485.         ol ("subq.l\t&4,%d0");
  2486.     else
  2487.         ol ("subq.l\t&1,%d0");
  2488. }
  2489.  
  2490. /*
  2491.  *    following are the conditional operators.
  2492.  *    they compare the secondary register against the primary register
  2493.  *    and put a literl 1 in the primary if the condition is true,
  2494.  *    otherwise they clear the primary register
  2495.  *
  2496.  */
  2497.  
  2498. /*
  2499.  *    equal
  2500.  *
  2501.  */
  2502. geq ()
  2503. {
  2504.     gcall ("^eq");
  2505.     stkp = stkp + INTSIZE;
  2506. }
  2507.  
  2508. /*
  2509.  *    not equal
  2510.  *
  2511.  */
  2512. gne ()
  2513. {
  2514.     gcall ("^ne");
  2515.     stkp = stkp + INTSIZE;
  2516. }
  2517.  
  2518. /*
  2519.  *    less than (signed)
  2520.  *
  2521.  */
  2522. glt ()
  2523. {
  2524.     gcall ("^lt");
  2525.     stkp = stkp + INTSIZE;
  2526. }
  2527. /*
  2528.  *    less than or equal (signed)
  2529.  *
  2530.  */
  2531. gle ()
  2532. {
  2533.     gcall ("^le");
  2534.     stkp = stkp + INTSIZE;
  2535. }
  2536.  
  2537. /*
  2538.  *    greater than (signed)
  2539.  *
  2540.  */
  2541. ggt ()
  2542. {
  2543.     gcall ("^gt");
  2544.     stkp = stkp + INTSIZE;
  2545. }
  2546.  
  2547. /*
  2548.  *    greater than or equal (signed)
  2549.  *
  2550.  */
  2551. gge ()
  2552. {
  2553.     gcall ("^ge");
  2554.     stkp = stkp + INTSIZE;
  2555. }
  2556.  
  2557. /*
  2558.  *    less than (unsigned)
  2559.  *
  2560.  */
  2561. gult ()
  2562. {
  2563.     gcall ("^ult");
  2564.     stkp = stkp + INTSIZE;
  2565. }
  2566.  
  2567. /*
  2568.  *    less than or equal (unsigned)
  2569.  *
  2570.  */
  2571. gule ()
  2572. {
  2573.     gcall ("^ule");
  2574.     stkp = stkp + INTSIZE;
  2575. }
  2576.  
  2577. /*
  2578.  *    greater than (unsigned)
  2579.  *
  2580.  */
  2581. gugt ()
  2582. {
  2583.     gcall ("^ugt");
  2584.     stkp = stkp + INTSIZE;
  2585. }
  2586.  
  2587. /*
  2588.  *    greater than or equal (unsigned)
  2589.  *
  2590.  */
  2591. guge ()
  2592. {
  2593.     gcall ("^uge");
  2594.     stkp = stkp + INTSIZE;
  2595. }
  2596.  
  2597. inclib() {
  2598. #ifdef    flex
  2599.     return("B.");
  2600. #endif
  2601. #ifdef    unix
  2602.     return(INCDIR);
  2603. #endif
  2604. #ifdef    cpm
  2605.     return("B:");
  2606. #endif
  2607. }
  2608.  
  2609. /*    Squirrel away argument count in a register that modstk/getloc/stloc
  2610.     doesn't touch.
  2611. */
  2612.  
  2613. gnargs(d)
  2614. int    d; {
  2615.     ot ("mov.l\t&");
  2616.     onum(d);
  2617.     outstr(",%d3\n");
  2618. }
  2619.  
  2620. #ifndef    NOASLD
  2621. char    assems[400];
  2622. int    assinit;
  2623. assemble(s)
  2624. char    *s; {
  2625. #ifdef    ASNM
  2626.     char    cmd[100],buf[100];
  2627.     char    *p;
  2628.     int    ex, rc, delaft;
  2629. #ifdef    unix
  2630.     p = strrchr(s, '/');
  2631.     if (p)
  2632.         strcat(buf, p+1);
  2633.     else
  2634. #endif
  2635.         strcat(buf, s);
  2636.     p = buf + strlen(buf) - 1;
  2637.     rc = typeof(s);
  2638.     delaft = (rc == 'c');
  2639.     if (rc == 'c' || rc == 's') {
  2640.         ex = 0;
  2641.         *p = 'o';
  2642.     } else
  2643.         ex = 1;
  2644.     if (!assinit) {
  2645.         strcat(assems, LDNM);
  2646.         assinit = 1;
  2647.     }
  2648.     strcat(assems, buf);
  2649.     strcat(assems, " ");
  2650.     if (ex)
  2651.         return(0);
  2652.     strcpy(cmd, ASNM);
  2653.     strcat(cmd, buf);
  2654.     strcat(cmd, " ");
  2655.     *p = 's';
  2656.     strcat(cmd, buf);
  2657.     rc = system(cmd);
  2658.     if (!rc && delaft)
  2659.         unlink(buf);
  2660.     return(rc);
  2661. #else
  2662.     return(0);
  2663. #endif
  2664. }
  2665.  
  2666. link() {
  2667. #ifdef    LDNM
  2668. #ifdef    unix
  2669. #ifdef    m68k
  2670.     strcat(assems, " -lc");
  2671. #else
  2672.     strcat(assems, " /u1/cx/lib/libc.a");
  2673. #endif
  2674. #endif
  2675.     return(system(assems));
  2676. #else
  2677.     return(0);
  2678. #endif
  2679. }
  2680. #endif
  2681. SHAR_EOF
  2682. if test 11259 -ne "`wc -c < 'codem68k.c'`"
  2683. then
  2684.     echo shar: error transmitting "'codem68k.c'" '(should have been 11259 characters)'
  2685. fi
  2686. fi
  2687. echo shar: extracting "'codevax.c'" '(10274 characters)'
  2688. if test -f 'codevax.c'
  2689. then
  2690.     echo shar: will not over-write existing file "'codevax.c'"
  2691. else
  2692. cat << \SHAR_EOF > 'codevax.c'
  2693. /*    File codevax.c: 2.2 (84/08/31,10:05:16) */
  2694. /*% cc -O -c %
  2695.  *
  2696.  */
  2697.  
  2698. #include <stdio.h>
  2699. #include "defs.h"
  2700. #include "data.h"
  2701.  
  2702. #ifdef    vax
  2703. #define    ASNM    "/bin/as"
  2704. #define    LDNM    "/bin/ld"
  2705. #endif
  2706.  
  2707. /*    Define ASNM and LDNM to the names of the assembler and linker
  2708.     respectively */
  2709.  
  2710. int    needr0;
  2711. int    needh;
  2712. /*
  2713.  *    Some predefinitions:
  2714.  *
  2715.  *    INTSIZE is the size of an integer in the target machine
  2716.  *    BYTEOFF is the offset of an byte within an integer on the
  2717.  *        target machine. (ie: 8080,pdp11 = 0, 6809 = 1,
  2718.  *        360 = 3)
  2719.  *    This compiler assumes that an integer is the SAME length as
  2720.  *    a pointer - in fact, the compiler uses INTSIZE for both.
  2721.  */
  2722. #define    INTSIZE    4
  2723. #define    BYTEOFF    0
  2724.  
  2725. /*
  2726.  *    print all assembler info before any code is generated
  2727.  *
  2728.  */
  2729. header ()
  2730. {
  2731.     outstr("#\tSmall C VAX\n#\tCoder (2.4,84/11/27)\n#");
  2732.     FEvers();
  2733.     nl ();
  2734.     ol (".globl\tlneg");
  2735.     ol (".globl\tcase");
  2736.     ol (".globl\teq");
  2737.     ol (".globl\tne");
  2738.     ol (".globl\tlt");
  2739.     ol (".globl\tle");
  2740.     ol (".globl\tgt");
  2741.     ol (".globl\tge");
  2742.     ol (".globl\tult");
  2743.     ol (".globl\tule");
  2744.     ol (".globl\tugt");
  2745.     ol (".globl\tuge");
  2746.     ol (".globl\tbool");
  2747. }
  2748.  
  2749. nl()
  2750. {
  2751.     if (needh) {
  2752.         ol (".word\t0");
  2753.         needh = 0;
  2754.     }
  2755.     if (needr0) {
  2756.         needr0 = 0;
  2757.         outstr(",r0");
  2758.     }
  2759.     outbyte(EOL);
  2760. }
  2761.  
  2762. initmac() {
  2763.     defmac("vax\t1");
  2764.     defmac("unix\t1");
  2765.     defmac("smallc\t1");
  2766. }
  2767.  
  2768. galign(t)
  2769. int t;
  2770. {
  2771.     int sign;
  2772.     if (t < 0) {
  2773.         sign = 1;
  2774.         t = -t;
  2775.     } else
  2776.         sign = 0;
  2777.     t = (t + INTSIZE - 1) & ~(INTSIZE - 1);
  2778.     t = sign? -t: t;
  2779.     return (t);
  2780. }
  2781.  
  2782.  
  2783.  
  2784. /*
  2785.  *    return size of an integer
  2786.  */
  2787. intsize() {
  2788.     return(INTSIZE);
  2789. }
  2790.  
  2791. /*
  2792.  *    return offset of ls byte within word
  2793.  *    (ie: 8080 & pdp11 is 0, 6809 is 1, 360 is 3)
  2794.  */
  2795. byteoff() {
  2796.     return(BYTEOFF);
  2797. }
  2798.  
  2799. /*
  2800.  *    Output internal generated label prefix
  2801.  */
  2802. olprfix() {
  2803.     outstr("LL");
  2804. }
  2805.  
  2806. /*
  2807.  *    Output a label definition terminator
  2808.  */
  2809. col ()
  2810. {
  2811.     outstr (":\n");
  2812. }
  2813.  
  2814. /*
  2815.  *    begin a comment line for the assembler
  2816.  *
  2817.  */
  2818. comment ()
  2819. {
  2820.     outbyte ('#');
  2821. }
  2822.  
  2823. /*
  2824.  *    Output a prefix in front of user labels
  2825.  */
  2826. prefix () {
  2827.     outbyte ('_');
  2828. }
  2829.  
  2830.  
  2831. /*
  2832.  *    print any assembler stuff needed after all code
  2833.  *
  2834.  */
  2835. trailer ()
  2836. {
  2837. }
  2838.  
  2839. /*
  2840.  *    function prologue
  2841.  */
  2842. prologue ()
  2843. {
  2844.     ol (".align\t1");
  2845. }
  2846.  
  2847. /*
  2848.  *    text (code) segment
  2849.  */
  2850. gtext ()
  2851. {
  2852.     ol (".text");
  2853. }
  2854.  
  2855. /*
  2856.  *    data segment
  2857.  */
  2858. gdata ()
  2859. {
  2860.     ol (".data");
  2861. }
  2862.  
  2863. /*
  2864.  *  Output the variable symbol at scptr as an extrn or a public
  2865.  */
  2866. ppubext(scptr) char *scptr; {
  2867.     if (scptr[STORAGE] == STATIC) return;
  2868.     ot (".globl\t");
  2869.     prefix ();
  2870.     outstr (scptr);
  2871.     nl();
  2872. }
  2873.  
  2874. /*
  2875.  * Output the function symbol at scptr as an extrn or a public
  2876.  */
  2877. fpubext(scptr) char *scptr; {
  2878.     ppubext(scptr);
  2879. }
  2880.  
  2881. /*
  2882.  *  Output a decimal number to the assembler file
  2883.  */
  2884. onum(num) int num; {
  2885.     outdec(num);    /* pdp11 needs a "." here */
  2886. }
  2887.  
  2888.  
  2889. /*
  2890.  *    fetch a static memory cell into the primary register
  2891.  */
  2892. getmem (sym)
  2893. char    *sym;
  2894. {
  2895.     if ((sym[IDENT] != POINTER) & (sym[TYPE] == CCHAR)) {
  2896.         ot ("cvtbl\t");
  2897.         prefix ();
  2898.         outstr (sym + NAME);
  2899.     } else {
  2900.         ot ("movl\t");
  2901.         prefix ();
  2902.         outstr (sym + NAME);
  2903.     }
  2904.     outstr(",r0\n");
  2905. }
  2906.  
  2907. /*
  2908.  *    fetch the address of the specified symbol into the primary register
  2909.  *
  2910.  */
  2911. getloc (sym)
  2912. char    *sym;
  2913. {
  2914.     if (sym[STORAGE] == LSTATIC) {
  2915.         immed();
  2916.         printlabel(glint(sym));
  2917.         nl();
  2918.     } else {
  2919.         ot ("moval\t");
  2920.         onum (glint(sym) - stkp);
  2921.         outstr ("(sp),r0\n");
  2922.     }
  2923. }
  2924.  
  2925. /*
  2926.  *    store the primary register into the specified static memory cell
  2927.  *
  2928.  */
  2929. putmem (sym)
  2930. char    *sym;
  2931. {
  2932.     if ((sym[IDENT] != POINTER) & (sym[TYPE] == CCHAR)) {
  2933.         ot ("cvtlb\tr0,");
  2934.     } else
  2935.         ot ("movl\tr0,");
  2936.     prefix ();
  2937.     outstr (sym + NAME);
  2938.     nl ();
  2939. }
  2940.  
  2941. /*
  2942.  *    store the specified object type in the primary register
  2943.  *    at the address on the top of the stack
  2944.  *
  2945.  */
  2946. putstk (typeobj)
  2947. char    typeobj;
  2948. {
  2949.     if (typeobj == CCHAR)
  2950.         ol ("cvtlb\tr0,*(sp)+");
  2951.     else
  2952.         ol ("movl\tr0,*(sp)+");
  2953.     stkp = stkp + INTSIZE;
  2954. }
  2955.  
  2956. /*
  2957.  *    fetch the specified object type indirect through the primary
  2958.  *    register into the primary register
  2959.  *
  2960.  */
  2961. indirect (typeobj)
  2962. char    typeobj;
  2963. {
  2964.     if (typeobj == CCHAR)
  2965.         ol ("cvtbl\t(r0),r0");
  2966.     else
  2967.         ol ("movl\t(r0),r0");
  2968. }
  2969.  
  2970. /*
  2971.  *    swap the primary and secondary registers
  2972.  *
  2973.  */
  2974. swap ()
  2975. {
  2976.     ol ("movl\tr0,r2\n\tmovl\tr1,r0\n\tmovl\tr2,r1");
  2977. }
  2978.  
  2979. /*
  2980.  *    print partial instruction to get an immediate value into
  2981.  *    the primary register
  2982.  *
  2983.  */
  2984. immed ()
  2985. {
  2986.     ot ("movl\t$");
  2987.     needr0 = 1;
  2988. }
  2989.  
  2990. /*
  2991.  *    push the primary register onto the stack
  2992.  *
  2993.  */
  2994. gpush ()
  2995. {
  2996.     ol ("pushl\tr0");
  2997.     stkp = stkp - INTSIZE;
  2998. }
  2999.  
  3000. /*
  3001.  *    pop the top of the stack into the secondary register
  3002.  *
  3003.  */
  3004. gpop ()
  3005. {
  3006.     ol ("movl\t(sp)+,r1");
  3007.     stkp = stkp + INTSIZE;
  3008. }
  3009.  
  3010. /*
  3011.  *    swap the primary register and the top of the stack
  3012.  *
  3013.  */
  3014. swapstk ()
  3015. {
  3016.     ol ("popl\tr2\npushl\tr0\nmovl\tr2,r0");
  3017. }
  3018.  
  3019. /*
  3020.  *    call the specified subroutine name
  3021.  *
  3022.  */
  3023. gcall (sname)
  3024. char    *sname;
  3025. {
  3026.     if (*sname == '^') {
  3027.         ot ("jsb\t");
  3028.         outstr (++sname);
  3029.     } else {
  3030.         ot ("jsb\t");
  3031.         prefix ();
  3032.         outstr (sname);
  3033.     }
  3034.     nl ();
  3035. }
  3036.  
  3037. /*
  3038.  *    return from subroutine
  3039.  *
  3040.  */
  3041. gret ()
  3042. {
  3043.     ol ("rsb");
  3044. }
  3045.  
  3046. /*
  3047.  *    perform subroutine call to value on top of stack
  3048.  *
  3049.  */
  3050. callstk ()
  3051. {
  3052.     ol ("jsb\t(sp)+");
  3053.     stkp = stkp + INTSIZE;
  3054. }
  3055.  
  3056. /*
  3057.  *    jump to specified internal label number
  3058.  *
  3059.  */
  3060. jump (label)
  3061. int    label;
  3062. {
  3063.     ot ("jmp\t");
  3064.     printlabel (label);
  3065.     nl ();
  3066. }
  3067.  
  3068. /*
  3069.  *    test the primary register and jump if false to label
  3070.  *
  3071.  */
  3072. testjump (label, ft)
  3073. int    label,
  3074.     ft;
  3075. {
  3076.     ol ("cmpl\tr0,$0");
  3077.     if (ft)
  3078.         ot ("jneq\t");
  3079.     else
  3080.         ot ("jeql\t");
  3081.     printlabel (label);
  3082.     nl ();
  3083. }
  3084.  
  3085. /*
  3086.  *    print pseudo-op  to define a byte
  3087.  *
  3088.  */
  3089. defbyte ()
  3090. {
  3091.     ot (".byte\t");
  3092. }
  3093.  
  3094. /*
  3095.  *    print pseudo-op to define storage
  3096.  *
  3097.  */
  3098. defstorage ()
  3099. {
  3100.     ot (".space\t");
  3101. }
  3102.  
  3103. /*
  3104.  *    print pseudo-op to define a word
  3105.  *
  3106.  */
  3107. defword ()
  3108. {
  3109.     ot (".long\t");
  3110. }
  3111.  
  3112. /*
  3113.  *    modify the stack pointer to the new value indicated
  3114.  *
  3115.  */
  3116. modstk (newstkp)
  3117. int    newstkp;
  3118. {
  3119.     int    k;
  3120.  
  3121.     k = newstkp - stkp;
  3122.     if (k % INTSIZE)
  3123.         error("Bad stack alignment (compiler error)");
  3124.     if (k == 0)
  3125.         return (newstkp);
  3126.     ot ("addl2\t$");
  3127.     onum (k);
  3128.     outstr (",sp");
  3129.     nl();
  3130.     return (newstkp);
  3131. }
  3132.  
  3133. /*
  3134.  *    multiply the primary register by INTSIZE
  3135.  */
  3136. gaslint ()
  3137. {
  3138.     ol ("ashl\t$2,r0,r0");
  3139. }
  3140.  
  3141. /*
  3142.  *    divide the primary register by INTSIZE
  3143.  */
  3144. gasrint()
  3145. {
  3146.     ol ("ashl\t$-2,r0,r0");
  3147. }
  3148.  
  3149. /*
  3150.  *    Case jump instruction
  3151.  */
  3152. gjcase() {
  3153.     ot ("jmp\tcase");
  3154.     nl ();
  3155. }
  3156.  
  3157. /*
  3158.  *    add the primary and secondary registers
  3159.  *    if lval2 is int pointer and lval is int, scale lval
  3160.  */
  3161. gadd (lval, lval2) int *lval, *lval2;
  3162. {
  3163.     if (dbltest (lval2, lval)) {
  3164.         ol ("ashl\t$2,(sp),(sp)");
  3165.     }
  3166.     ol ("addl2\t(sp)+,r0");
  3167.     stkp = stkp + INTSIZE;
  3168. }
  3169.  
  3170. /*
  3171.  *    subtract the primary register from the secondary
  3172.  *
  3173.  */
  3174. gsub ()
  3175. {
  3176.     ol ("subl3\tr0,(sp)+,r0");
  3177.     stkp = stkp + INTSIZE;
  3178. }
  3179.  
  3180. /*
  3181.  *    multiply the primary and secondary registers
  3182.  *    (result in primary)
  3183.  *
  3184.  */
  3185. gmult ()
  3186. {
  3187.     ol ("mull2\t(sp)+,r0");
  3188.     stkp = stkp + INTSIZE;
  3189. }
  3190.  
  3191. /*
  3192.  *    divide the secondary register by the primary
  3193.  *    (quotient in primary, remainder in secondary)
  3194.  *
  3195.  */
  3196. gdiv ()
  3197. {
  3198.     ol ("divl3\tr0,(sp)+,r0");
  3199.     stkp = stkp + INTSIZE;
  3200. }
  3201.  
  3202. /*
  3203.  *    compute the remainder (mod) of the secondary register
  3204.  *    divided by the primary register
  3205.  *    (remainder in primary, quotient in secondary)
  3206.  *
  3207.  */
  3208. gmod ()
  3209. {
  3210.     ol ("movl\t(sp)+,r2\n\tmovl\t$0,r3\nediv\tr0,r2,r1,r0");
  3211.     stkp = stkp + INTSIZE;
  3212. }
  3213.  
  3214. /*
  3215.  *    inclusive 'or' the primary and secondary registers
  3216.  *
  3217.  */
  3218. gor ()
  3219. {
  3220.     ol ("bisl2\t(sp)+,r0");
  3221.     stkp = stkp + INTSIZE;
  3222. }
  3223.  
  3224. /*
  3225.  *    exclusive 'or' the primary and secondary registers
  3226.  *
  3227.  */
  3228. gxor ()
  3229. {
  3230.     ol ("xorl2\t(sp)+,r0");
  3231.     stkp = stkp + INTSIZE;
  3232. }
  3233.  
  3234. /*
  3235.  *    'and' the primary and secondary registers
  3236.  *
  3237.  */
  3238. gand ()
  3239. {
  3240.     ol ("mcoml\t(sp)+,r1\n\tbicl2\tr1,r0");
  3241.     stkp = stkp + INTSIZE;
  3242. }
  3243.  
  3244. /*
  3245.  *    arithmetic shift right the secondary register the number of
  3246.  *    times in the primary register
  3247.  *    (results in primary register)
  3248.  *
  3249.  */
  3250. gasr ()
  3251. {
  3252.     ol("mnegl\tr0,r0\n\tashl\tr0,(sp)+,r0");
  3253.     stkp = stkp + INTSIZE;
  3254. }
  3255.  
  3256. /*
  3257.  *    arithmetic shift left the secondary register the number of
  3258.  *    times in the primary register
  3259.  *    (results in primary register)
  3260.  *
  3261.  */
  3262. gasl ()
  3263. {
  3264.     ol ("ashl\tr0,(sp)+,r0");
  3265.     stkp = stkp + INTSIZE;
  3266. }
  3267.  
  3268. /*
  3269.  *    two's complement of primary register
  3270.  *
  3271.  */
  3272. gneg ()
  3273. {
  3274.     ol ("mnegl\tr0,r0");
  3275. }
  3276.  
  3277. /*
  3278.  *    logical complement of primary register
  3279.  *
  3280.  */
  3281. glneg ()
  3282. {
  3283.     gcall ("^lneg");
  3284. }
  3285.  
  3286. /*
  3287.  *    one's complement of primary register
  3288.  *
  3289.  */
  3290. gcom ()
  3291. {
  3292.     ol ("mcoml\tr0,r0");
  3293. }
  3294.  
  3295. /*
  3296.  *    convert primary register into logical value
  3297.  *
  3298.  */
  3299. gbool ()
  3300. {
  3301.     gcall ("^bool");
  3302. }
  3303. /*
  3304.  *    increment the primary register by 1 if char, INTSIZE if
  3305.  *      int
  3306.  */
  3307. ginc (lval) int lval[];
  3308. {
  3309.     if (lval[2] == CINT)
  3310.         ol ("addl2\t$4,r0");
  3311.     else
  3312.         ol ("incl\tr0");
  3313. }
  3314.  
  3315. /*
  3316.  *    decrement the primary register by one if char, INTSIZE if
  3317.  *    int
  3318.  */
  3319. gdec (lval) int lval[];
  3320. {
  3321.     if (lval[2] == CINT)
  3322.         ol ("subl2\t$4,r0");
  3323.     else
  3324.         ol ("decl\tr0");
  3325. }
  3326.  
  3327. /*
  3328.  *    following are the conditional operators.
  3329.  *    they compare the secondary register against the primary register
  3330.  *    and put a literl 1 in the primary if the condition is true,
  3331.  *    otherwise they clear the primary register
  3332.  *
  3333.  */
  3334.  
  3335. /*
  3336.  *    equal
  3337.  *
  3338.  */
  3339. geq ()
  3340. {
  3341.     gcall ("^eq");
  3342.     stkp = stkp + INTSIZE;
  3343. }
  3344.  
  3345. /*
  3346.  *    not equal
  3347.  *
  3348.  */
  3349. gne ()
  3350. {
  3351.     gcall ("^ne");
  3352.     stkp = stkp + INTSIZE;
  3353. }
  3354.  
  3355. /*
  3356.  *    less than (signed)
  3357.  *
  3358.  */
  3359. glt ()
  3360. {
  3361.     gcall ("^lt");
  3362.     stkp = stkp + INTSIZE;
  3363. }
  3364. /*
  3365.  *    less than or equal (signed)
  3366.  *
  3367.  */
  3368. gle ()
  3369. {
  3370.     gcall ("^le");
  3371.     stkp = stkp + INTSIZE;
  3372. }
  3373.  
  3374. /*
  3375.  *    greater than (signed)
  3376.  *
  3377.  */
  3378. ggt ()
  3379. {
  3380.     gcall ("^gt");
  3381.     stkp = stkp + INTSIZE;
  3382. }
  3383.  
  3384. /*
  3385.  *    greater than or equal (signed)
  3386.  *
  3387.  */
  3388. gge ()
  3389. {
  3390.     gcall ("^ge");
  3391.     stkp = stkp + INTSIZE;
  3392. }
  3393.  
  3394. /*
  3395.  *    less than (unsigned)
  3396.  *
  3397.  */
  3398. gult ()
  3399. {
  3400.     gcall ("^ult");
  3401.     stkp = stkp + INTSIZE;
  3402. }
  3403.  
  3404. /*
  3405.  *    less than or equal (unsigned)
  3406.  *
  3407.  */
  3408. gule ()
  3409. {
  3410.     gcall ("^ule");
  3411.     stkp = stkp + INTSIZE;
  3412. }
  3413.  
  3414. /*
  3415.  *    greater than (unsigned)
  3416.  *
  3417.  */
  3418. gugt ()
  3419. {
  3420.     gcall ("^ugt");
  3421.     stkp = stkp + INTSIZE;
  3422. }
  3423.  
  3424. /*
  3425.  *    greater than or equal (unsigned)
  3426.  *
  3427.  */
  3428. guge ()
  3429. {
  3430.     gcall ("^uge");
  3431.     stkp = stkp + INTSIZE;
  3432. }
  3433.  
  3434. /*    Squirrel away argument count in a register that modstk
  3435.     doesn't touch.
  3436. */
  3437.  
  3438. gnargs(d)
  3439. int    d; {
  3440.     ot ("movl\t$");
  3441.     onum(d);
  3442.     outstr (",r6\n");
  3443. }
  3444.  
  3445. inclib() {
  3446. #ifdef    flex
  3447.     return("B.");
  3448. #endif
  3449. #ifdef    unix
  3450.     return(INCDIR);
  3451. #endif
  3452. #ifdef    cpm
  3453.     return("B:");
  3454. #endif
  3455. }
  3456.  
  3457. assemble(s)
  3458. char    *s; {
  3459. #ifdef    ASNM
  3460.     char buf[100];
  3461.     strcpy(buf, ASNM);
  3462.     strcat(buf, " -o ");
  3463.     strcat(buf, s);
  3464.     buf[strlen(buf)-1] = 'o';
  3465.     strcat(buf, " ");
  3466.     strcat(buf, s);
  3467.     buf[strlen(buf)-1] = 's';
  3468.     return(system(buf));
  3469. #else
  3470.     return(0);
  3471. #endif
  3472. }
  3473.  
  3474. link() {
  3475. #ifdef    LDNM
  3476.     fputs("I don't know how to link files yet\n", stderr);
  3477. #else
  3478.     return(0);
  3479. #endif
  3480. }
  3481. SHAR_EOF
  3482. if test 10274 -ne "`wc -c < 'codevax.c'`"
  3483. then
  3484.     echo shar: error transmitting "'codevax.c'" '(should have been 10274 characters)'
  3485. fi
  3486. fi
  3487. echo shar: extracting "'data.c'" '(722 characters)'
  3488. if test -f 'data.c'
  3489. then
  3490.     echo shar: will not over-write existing file "'data.c'"
  3491. else
  3492. cat << \SHAR_EOF > 'data.c'
  3493. /*    File data.c: 2.2 (84/11/27,16:26:13) */
  3494. /*% cc -O -c %
  3495.  *
  3496.  */
  3497.  
  3498. #include <stdio.h>
  3499. #include "defs.h"
  3500.  
  3501. /* storage words */
  3502.  
  3503. char    symtab[SYMTBSZ];
  3504. char    *glbptr, *rglbptr, *locptr;
  3505. int    ws[WSTABSZ];
  3506. int    *wsptr;
  3507. int    swstcase[SWSTSZ];
  3508. int    swstlab[SWSTSZ];
  3509. int    swstp;
  3510. char    litq[LITABSZ];
  3511. int    litptr;
  3512. char    macq[MACQSIZE];
  3513. int    macptr;
  3514. char    line[LINESIZE];
  3515. char    mline[LINESIZE];
  3516. int    lptr, mptr;
  3517.  
  3518. /* miscellaneous storage */
  3519.  
  3520. int    nxtlab,
  3521.     litlab,
  3522.     stkp,
  3523.     argstk,
  3524.     ncmp,
  3525.     errcnt,
  3526.     glbflag,
  3527.     ctext,
  3528.     cmode,
  3529.     lastst;
  3530.  
  3531. FILE    *input, *input2, *output;
  3532. FILE    *inclstk[INCLSIZ];
  3533. int    inclsp;
  3534. char    fname[20];
  3535.  
  3536. char    quote[2];
  3537. char    *cptr;
  3538. int    *iptr;
  3539. int    fexitlab;
  3540. int    iflevel, skiplevel;
  3541. int    errfile;
  3542. int    sflag;
  3543. int    cflag;
  3544. int    errs;
  3545. int    aflag;
  3546. SHAR_EOF
  3547. if test 722 -ne "`wc -c < 'data.c'`"
  3548. then
  3549.     echo shar: error transmitting "'data.c'" '(should have been 722 characters)'
  3550. fi
  3551. fi
  3552. echo shar: extracting "'data.h'" '(807 characters)'
  3553. if test -f 'data.h'
  3554. then
  3555.     echo shar: will not over-write existing file "'data.h'"
  3556. else
  3557. cat << \SHAR_EOF > 'data.h'
  3558. /*    File data.h: 2.2 (84/11/27,16:26:11) */
  3559.  
  3560. /* storage words */
  3561.  
  3562. extern    char    symtab[];
  3563. extern    char    *glbptr, *rglbptr, *locptr;
  3564. extern    int    ws[];
  3565. extern    int    *wsptr;
  3566. extern    int    swstcase[];
  3567. extern    int    swstlab[];
  3568. extern    int    swstp;
  3569. extern    char    litq[];
  3570. extern    int    litptr;
  3571. extern    char    macq[];
  3572. extern    int    macptr;
  3573. extern    char    line[];
  3574. extern    char    mline[];
  3575. extern    int    lptr, mptr;
  3576.  
  3577. /* miscellaneous storage */
  3578.  
  3579. extern    int    nxtlab,
  3580.         litlab,
  3581.         stkp,
  3582.         argstk,
  3583.         ncmp,
  3584.         errcnt,
  3585.         glbflag,
  3586.         ctext,
  3587.         cmode,
  3588.         lastst;
  3589.  
  3590. extern    FILE    *input, *input2, *output;
  3591. extern    FILE    *inclstk[];
  3592. extern    int    inclsp;
  3593. extern    char    fname[];
  3594.  
  3595. extern    char    quote[];
  3596. extern    char    *cptr;
  3597. extern    int    *iptr;
  3598. extern    int    fexitlab;
  3599. extern    int    iflevel, skiplevel;
  3600. extern    int    errfile;
  3601. extern    int    sflag;
  3602. extern    int    cflag;
  3603. extern    int    errs;
  3604. extern    int    aflag;
  3605. SHAR_EOF
  3606. if test 807 -ne "`wc -c < 'data.h'`"
  3607. then
  3608.     echo shar: error transmitting "'data.h'" '(should have been 807 characters)'
  3609. fi
  3610. fi
  3611. exit 0
  3612. #    End of shell archive
  3613.